Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15842

Re: Preventing Bash Variable Confusion

From Roger <rogerx.oss@gmail.com>
Newsgroups gnu.bash.bug
Subject Re: Preventing Bash Variable Confusion
Date 2020-01-29 13:05 -0500
Message-ID <mailman.50.1580321118.2384.bug-bash@gnu.org> (permalink)
References <20200128210225.GC12574@localhost4.local> <20806.1580277461@jinx.noi.kre.to> <20200129142305.GX1350@eeg.ccf.org> <20200129180511.GA5533@localhost4.local>

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

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/

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: Preventing Bash Variable Confusion Roger <rogerx.oss@gmail.com> - 2020-01-29 13:05 -0500

csiph-web