[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Preventing Bash Variable Confusion

From: Roger
Subject: Re: Preventing Bash Variable Confusion
Date: Wed, 29 Jan 2020 13:05:11 -0500
User-agent: Mutt/1.10.1 (2018-07-13)


So $mVARIABLE is an alternative.  However, per Google style and my preference, 
mixed seems messy.  I thought camel/mixed case increased readability years ago, 
but over time I typed my_variable or my_function_name (C code) much easier as 
well as read easier.  The missing space char between words seems to condone 
confusion when attempting to read script/code naturally.  All capitol case 
variable names were extremely visible when reading code, but seems now to be 
explicitly reserved for OS intercommunication use.

I think I prefer the style; $_variable, $my_variable and f_functionname.  
Google style documentation cited the "$_" prefix satisfied uniqueness from OS 
related variable names as well as supposedly increasing readability or 
distinguishing variables from the rest of the scripting language.

Also the use of local defined variables within functions is probably desirable. 
I'll start incorporating these techniques within my scripts as well as likely 
incorporating a trap protection within loops calling non-builtin commands.

For reference:

Shell Style Guide

Ky-Anh Huynh icy (Popular Hit)
Seems to be a duplicate of Google's style guide.


Attachment: signature.asc
Description: Digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]