bug-bash
[Top][All Lists]
Advanced

[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)

Awesome.

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:

Google
Shell Style Guide
https://google.github.io/styleguide/shell.xml


Ky-Anh Huynh icy (Popular Hit)
https://github.com/icy/bash-coding-style
Seems to be a duplicate of Google's style guide.



-- 
Roger
http://rogerx.sdf.org/

Attachment: signature.asc
Description: Digital signature


reply via email to

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