From 805d81a949fa36b87d498b28be36bce5eff1d32d Mon Sep 17 00:00:00 2001 From: Eric Nielsen Date: Tue, 31 Aug 2021 18:58:03 -0500 Subject: [PATCH] Add recommendation about typeset -g --- Code-Style-Guide.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Code-Style-Guide.md b/Code-Style-Guide.md index 67ed9b6..1dbbd5b 100644 --- a/Code-Style-Guide.md +++ b/Code-Style-Guide.md @@ -32,6 +32,10 @@ Use existing variables whenever possible: * Good: `${PWD}` `${USER}` * Bad: `$(pwd)` `$(whoami)` +When declaring a global variable, be explicit and do it using `typeset -g`. This avoids warnings when `WARN_CREATE_GLOBAL` is set: +* Good: `if (( ! ${+VAR} )) typeset -g VAR=1` +* Bad: `: ${VAR=1}` + Flow logic ----------