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


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

Preventing Bash Variable Confusion

Started byRoger <rogerx.oss@gmail.com>
First post2020-01-28 16:02 -0500
Last post2020-01-28 16:02 -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

  Preventing Bash Variable Confusion Roger <rogerx.oss@gmail.com> - 2020-01-28 16:02 -0500

#15829 — Preventing Bash Variable Confusion

FromRoger <rogerx.oss@gmail.com>
Date2020-01-28 16:02 -0500
SubjectPreventing Bash Variable Confusion
Message-ID<mailman.263.1580245350.2185.bug-bash@gnu.org>

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

I've used Bash for quite some time now and have heard lots about how variables 
should be named or styled.

1) Bash internal reserved words cannot be used a variables.  (OK. All of us who 
have programmed code get this and of course abide whole heartedly, else we fail 
quickly!)

2) Operating System (Bash or other) reserved variables are all defined as 
capitol letters, and all capitol letter variables should be avoided within Bash 
scripts.  (I've heard of this, however, I enjoy defining my variables in all 
capitol letters due to the increased readability of the script ... or in 
essence, all capitol letters readily distinguishes variables from other Bash 
words and operators.)

Some say variables should be prefixed (or suffixed) to further distinguish Bash 
variables from possible collisions with operating system Bash or other related 
variables.

I've thought about using "_VARIABLE" and have seen similar, but also requires 
an extra odd stressed finger combination prior to typing all capitol letters.  
Typing all capitol letters can be stressful, but the task improves readability 
in my point of view that the time and effort are well worth the effort, until I 
get to the additional underscore.

When and if I program in C, I tend to use all lower case style, my_variable.

Anybody have any further insight concerning variable naming styles aside from 
what's already written within the documentation?

I could do something like MY_VARIABLE, but then prefixing with "MY_" eats up 
three more chars I could have used for describing my variable better.  
Shrugs...

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

[toc] | [standalone]


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


csiph-web