-
Notifications
You must be signed in to change notification settings - Fork 0
variables naming convenction
Naming conventions followed consistently will always help.
-
Use all caps and underscores for exported variables and constants. Use a common prefix whenever applicable so that related variables stand out.
Examples:
- Exported variables with a common prefix:
JOB_HOME
JOB_LOG
JOB_TEMP
JOB_RUN_CONTROL
- Constants:
PI
MAX_FILES
OK
ERROR
WARNING
- Exported variables with a common prefix:
-
Use "snake case" (all lowercase and underscores) for all variables that are scoped to a single script or a block.
Examples:
input_file
first_value
max_amount
num_errors
Mixed case when local variable has some relationship with an environment variable, like:
old_IFS
old_HOME
-
Use a leading underscore for "private" variables and functions. This is especially relevant if you ever write a shell library where functions within a library file or across files need to share variables, without ever clashing with anything that might be similarly named in the main code.
Examples:
_debug
_debug_level
_current_log_file
-
Never use camel case. This will make sure we don't run into bugs caused by case typos. Remember, shell variables are case sensitive.
Examples:
inputArray
thisLooksBAD
,numRecordsProcessed
,veryInconsistent_style