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


Groups > gnu.bash.bug > #15842 > unrolled thread

Re: Preventing Bash Variable Confusion

Started byRoger <rogerx.oss@gmail.com>
First post2020-01-29 13:05 -0500
Last post2020-01-29 13:05 -0500
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#15842 — Re: Preventing Bash Variable Confusion

FromRoger <rogerx.oss@gmail.com>
Date2020-01-29 13:05 -0500
SubjectRe: Preventing Bash Variable Confusion
Message-ID<mailman.50.1580321118.2384.bug-bash@gnu.org>

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

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web