[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Preventing Bash Variable Confusion
From: |
Roger |
Subject: |
Re: Preventing Bash Variable Confusion |
Date: |
Thu, 30 Jan 2020 01:40:18 -0500 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
> On Thu, Jan 30, 2020 at 11:37:26AM +0800, konsolebox wrote:
>
> Here's my take.
> You can still use all caps on global variables just mind the internal
> variables. You can have it prefixed by an underscore if you worry about
> conflicts.** You can also have it prefixed with the script's name in all
> caps.** It's best to have the variables initialized at the beginning if
> the script so it's explicit that you intend to use the variables as global
> variables of the script.
> And then you use lowercase on local.** Use an underscore or
> two-underscores prefix on indirect variables and never reference an
> indirect variable with another.** This includes passing the indirect
> variable for reference to another function.
> --
> konsolebox
I've thought about this, yes I can use that style. However...
1) Using an underslash on all capitol variable names just looks ugly in my
opinion. Or more to the point, the style seems to stray away from main stream
styles.
2) Prefixing variable names with the name of the script (or other lengthy
prefix) requires more characters I could be using for describing my variable or
function. (If I were writing unreadable code, I probably would not mind.)
I've decided to comply with Google's Style guidelines, even though they do not
pay me a paycheck, but they do give me lots of free stuff. Shrugs, besides,
the more my Bash scripting looks like C, the easier it is to read.
The can push me away from defining my variables in all capitol letters. They
can even push me to code in C and Assembly, but just don't push me to script in
Python.
--
Roger
http://rogerx.sdf.org/
- Re: Preventing Bash Variable Confusion, (continued)
- Re: Preventing Bash Variable Confusion, Robert Elz, 2020/01/29
- Re: Preventing Bash Variable Confusion, Greg Wooledge, 2020/01/29
- Re: Preventing Bash Variable Confusion, Roger, 2020/01/29
- Re: Preventing Bash Variable Confusion, Chet Ramey, 2020/01/29
- Re: Preventing Bash Variable Confusion, Roger, 2020/01/29
- Re: Preventing Bash Variable Confusion, Chris F.A. Johnson, 2020/01/30
- Re: Preventing Bash Variable Confusion, Robert Elz, 2020/01/30
Re: Preventing Bash Variable Confusion, konsolebox, 2020/01/29
- Re: Preventing Bash Variable Confusion,
Roger <=
Re: Preventing Bash Variable Confusion, Greg Wooledge, 2020/01/30