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


Groups > gnu.bash.bug > #15829

Preventing Bash Variable Confusion

Path csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From Roger <rogerx.oss@gmail.com>
Newsgroups gnu.bash.bug
Subject Preventing Bash Variable Confusion
Date Tue, 28 Jan 2020 16:02:25 -0500
Lines 76
Approved bug-bash@gnu.org
Message-ID <mailman.263.1580245350.2185.bug-bash@gnu.org> (permalink)
References <20200128210225.GC12574@localhost4.local>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="v9Ux+11Zm5mwPlX6"
X-Trace usenet.stanford.edu 1580245351 10998 209.51.188.17 (28 Jan 2020 21:02:31 GMT)
X-Complaints-To action@cs.stanford.edu
To bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=vBCrz+p1S5P1EPpYYLTH67Z9VW2s45lD6eC5Go6PZsI=; b=FpivGXoYlT/wwiM+Ft+ArFCpNlrcTezctoKejjcHaZAkk4K3SZtpE4wS7Un59nFj3Y gHSfSamNHA+8XIfmx1SVqV54LyQBNCyihCEIXoOKZVzudRaWUfP6VcccNdb3s6J8YJeT eykyt3Lgdy37ivOTFnGmkW1OQ2eVUTA0evsfgr58eJnGSG5/9fNiKSoDkDW0k8wn1aiA uxhs5iM/3+7MJKuCaaYwB75RZh7NHvPFcAc553mPETAsplaiLqUMolGAahwFbeF1qbI4 0Uno0BjvgZTZppO90DTSBwLM8EKHdrzPSubQKZaNt9EILv6S+W03qgnw8vM71opQBBq4 Ma7w==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=vBCrz+p1S5P1EPpYYLTH67Z9VW2s45lD6eC5Go6PZsI=; b=sBISEyO4ScShkog6sdjmhQ07nQ1X6ZGipzB0kZ3xu7BNVyamclgFAB0N84Qv/MGicC HYKLGEhO14zT4XUbxV83CJOxfA7v8pjy84QcuTZFJ1hFaCrfRr7ws3xf7KtphxVrsH1M cRniMKvv44O4af1taz7NGl++ZZSlz8URsAgX/Io7G8cwsYyANeDF3XYjntdFAIFZFZ6b E63iQFLVp2tY3as39ztLvaSIEV1ppkVImqiKpzYMqSZhVKdnzgy1NHdQojgydG0C5AWl EQyz2vLy7V8xi/50+JDQvrs89Dbpt6fKI4xrVu+k9dTjXvreU+tZUPtPl20MQn/Ae9DE v0lg==
X-Gm-Message-State APjAAAXzzJia/U7KK0y3/uf/vh/PwnrxA81XWMF9Ucy+bOz/+7RSH3DJ T0Ev4AN5Rj/QGzXUP0y+eNVWZoRe7gQ=
X-Google-Smtp-Source APXvYqwvc2KQWX6I7d98BQ/QeC+al8pqaHH9YYr4hWDNmjsp5uUriAB4B2dStWFLlkDivC436JoXAA==
X-Received by 2002:a37:801:: with SMTP id 1mr25397749qki.326.1580245346819; Tue, 28 Jan 2020 13:02:26 -0800 (PST)
Content-Disposition inline
X-PGP-Key http://rogerx.sdf.org/about/armor-F515AC1F231FFC4EF0BCDE7606CEA0ECE2887C75-20170104.asc
User-Agent Mutt/1.10.1 (2018-07-13)
X-detected-operating-system by eggs.gnu.org: Genre and OS details not recognized.
X-Received-From 2607:f8b0:4864:20::72d
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <20200128210225.GC12574@localhost4.local>
Xref csiph.com gnu.bash.bug:15829

Show key headers only | View raw


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

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


Thread

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

csiph-web