Path: csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail From: Roger 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: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <20200128210225.GC12574@localhost4.local> Xref: csiph.com gnu.bash.bug:15829 --v9Ux+11Zm5mwPlX6 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable I've used Bash for quite some time now and have heard lots about how variab= les=20 should be named or styled. 1) Bash internal reserved words cannot be used a variables. (OK. All of us= who=20 have programmed code get this and of course abide whole heartedly, else we = fail=20 quickly!) 2) Operating System (Bash or other) reserved variables are all defined as= =20 capitol letters, and all capitol letter variables should be avoided within = Bash=20 scripts. (I've heard of this, however, I enjoy defining my variables in al= l=20 capitol letters due to the increased readability of the script ... or in=20 essence, all capitol letters readily distinguishes variables from other Bas= h=20 words and operators.) Some say variables should be prefixed (or suffixed) to further distinguish = Bash=20 variables from possible collisions with operating system Bash or other rela= ted=20 variables. I've thought about using "_VARIABLE" and have seen similar, but also requir= es=20 an extra odd stressed finger combination prior to typing all capitol letter= s. =20 Typing all capitol letters can be stressful, but the task improves readabil= ity=20 in my point of view that the time and effort are well worth the effort, unt= il I=20 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 fr= om=20 what's already written within the documentation? I could do something like MY_VARIABLE, but then prefixing with "MY_" eats u= p=20 three more chars I could have used for describing my variable better. =20 Shrugs... --=20 Roger http://rogerx.sdf.org/ --v9Ux+11Zm5mwPlX6 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEE9RWsHyMf/E7wvN52Bs6g7OKIfHUFAl4woWEACgkQBs6g7OKI fHXiawf+NBWNkknWvprUrce5C3ulBiC4ycVumbeyEhjA0t36/YJYg/8XLQ6w4VZM 33/fDZsRPGvB0eoSvJeqXBhwKX/K4wf5dHpzfrZ+H5jrljwQqA8xmYloT5o1Hwq1 wk/5WgQOY6QO5elDbSCYXC+MacOM7Kh+LQaiRBjh2AJX2VSIk6UT0bZINHIQ6huF l1KG+8VWN8qh0DL4DFl8ji7iaBOzsOBP2JLU/QhJWvdmeTmWzm5pu7itJ8tSTgJC Yu1GIOXGthnfcAIqt5rtZ72dRPKs9oRQ3vWChw/CNwPC0tWfvs1zdVOx61JC9Vuj Hii6HkL2JqA+tQxsXNXhh2H/Aaqc3g== =lre7 -----END PGP SIGNATURE----- --v9Ux+11Zm5mwPlX6--