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


Groups > gnu.bash.bug > #15842

Re: 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 Re: Preventing Bash Variable Confusion
Date Wed, 29 Jan 2020 13:05:11 -0500
Lines 71
Approved bug-bash@gnu.org
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>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="uAKRQypu60I7Lcqm"
X-Trace usenet.stanford.edu 1580321118 16865 209.51.188.17 (29 Jan 2020 18:05:18 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:references:mime-version :content-disposition:in-reply-to:user-agent; bh=CDVkPlLuvk67Tcr2XnGl+hfE5sFKa/n1pNX5sqpfM6A=; b=RQ2U0DpiOatYZ1BKuFF3mlwlPreaXwImPIovU7cfnJ9P6jlKo5WSP7OIDIEydiZ96k 85GAbupbQeUdU3Zxk/VlrElNdhRyZDlmu0q7p/eduAbNkJ8S9W5Gep2OuDrqgFL97BO6 v7qFcS+L1nF9XP1fDBbw9AQP3xC5HmajzrWo5n+eCJBXeoC95cE11Pi9MMocDDN9ohu9 QTumLthtVvz6ogZDD2Qy6kMTJpFGpgh5CPptwi2w1Bavza6lYvAnyMRE2dGe8ljQo5zA VdVz0VKt87oc4iCaTnMiMBUBvN4Y/ei0vjjh0UQUF8iEDv4OyV2PmINQVKVMbJRzZOqL dMVQ==
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:references :mime-version:content-disposition:in-reply-to:user-agent; bh=CDVkPlLuvk67Tcr2XnGl+hfE5sFKa/n1pNX5sqpfM6A=; b=jVkpCB4W09jIjHs6uY4/bjdTI/QCxDBb9pDThFD55r85/jjSVmvHBg0PJv8qfimkJt zjIwQ2Ua6OnmhKkqURKbu69KBQXQa1Eb5cF73l07BCsagDjDDBQBTDmqZcPTylcNWwLp QKXpjdliV87KGPJzMz9nflm2etU9jnk8pRS05zNNcprjPMTyelO5UKyqD5VYcoqAmozN VLtEse4g6R9AMlJWNGHMVtkklSOUnbcLMKkpQCU5+oMVGOHROeFGAxYii0+a1YqAUv6S B7MMYchrdnVkwAChi0yBZZBfpkJpqSbknljoQ59GznG+e02sCnR2erCxcjtsZNel7p9K cXzA==
X-Gm-Message-State APjAAAUuJ2rvS1M0qamiLQ+CXVF+fALhByvyChmkupHMqmKLBpZbMWSq +0FlaAR+6scE1a40mx0mDdZxn53KabI=
X-Google-Smtp-Source APXvYqzWHLm+ywLd99ZLu5f53kmSwvTBXPyC6s6GxIbj1VG795QMkIyIKWjDuueY84tV8wX6BkhLEA==
X-Received by 2002:a37:a30a:: with SMTP id m10mr967708qke.56.1580321113275; Wed, 29 Jan 2020 10:05:13 -0800 (PST)
Content-Disposition inline
In-Reply-To <20200129142305.GX1350@eeg.ccf.org>
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::72f
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 <20200129180511.GA5533@localhost4.local>
X-Mailman-Original-References <20200128210225.GC12574@localhost4.local> <20806.1580277461@jinx.noi.kre.to> <20200129142305.GX1350@eeg.ccf.org>
Xref csiph.com gnu.bash.bug:15842

Show key headers only | 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