Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #15851
| Path | csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail |
|---|---|
| From | konsolebox <konsolebox@gmail.com> |
| Newsgroups | gnu.bash.bug |
| Subject | Re: Preventing Bash Variable Confusion |
| Date | Thu, 30 Jan 2020 11:37:26 +0800 |
| Lines | 28 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.88.1580355467.2384.bug-bash@gnu.org> (permalink) |
| References | <20200128210225.GC12574@localhost4.local> <CAJnmqwbr6EVJOZn6SLdByAgZAoFN60ahCp3m2HJyJ6VS=hwEvg@mail.gmail.com> |
| NNTP-Posting-Host | lists.gnu.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="UTF-8" |
| X-Trace | usenet.stanford.edu 1580355467 1869 209.51.188.17 (30 Jan 2020 03:37:47 GMT) |
| X-Complaints-To | action@cs.stanford.edu |
| Cc | bug-bash <bug-bash@gnu.org> |
| To | Roger <rogerx.oss@gmail.com> |
| Envelope-to | bug-bash@gnu.org |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RnGu4HtATol9tyMRj7VbijPbzp7IS/aZUk/zOWYaSsg=; b=WIsOuDejgIEb7jhDD/iy651JayyI0HFBkSvCG8ba+g73V0JuBfBCyF24lQKg9jBp+O iYclenGmp+figI2e4vXdyfqNqtFycST5tl0hiwUxxUO7JkiQm7ZSrNQbuVMgncj1e8zG 4LZhsOcW4gKnXZLIJjKws6d5BFX91v7KOcMXjZhE3dHGH8FMmxar9x6m1EFcZGgTbnmv wSfGHs2MCtnhDZUNveI2NMfMEiQ7qglbB1RCRL38L3cYRnFT1VeHYzdWe7sLqBNozA/9 d20d5q8bTeFC5Ix8m9BvqtucdSFgCx/DoQrmxUsJv5gGEd5oI9hgoh+qp/xv+/5HJgvB P4tw== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RnGu4HtATol9tyMRj7VbijPbzp7IS/aZUk/zOWYaSsg=; b=XUszfc22QbB1l89AWXxmCc1dI1jRa0GhnYBT+9i5lqZb7zAxupa+Vyvh2ob1kYQPbS 77ooVLLjZFaAWPSzNxe8+Cq6L6XSp/ym3dGXBb9jvFncREyJ5tNPY0LfVcyLF/WFX0SA C4s5N+FO2Ab7ACfua4Wr5FOhJckjiuag2itn7XQLpTbn8xtNv4NgM8P2oH4KWlT4NxRV RVttyZEzVGzMKFf98P8MKA0VO9MXcKBk8j8keMQ/dkX5t+F4tvhucbr6Vd4sDSrqrXYB woX1UqDdpF/uA0hTIeRRTUd2EF4R+uklIHkT3+49Irhm3iQd8+mPFhLDziOERiiJjjcE +EHw== |
| X-Gm-Message-State | APjAAAXh6mZoamEXu6vzkFK31cIR6G3Ji65Y83EXPLba86/ZKPBeUBW6 dgtoYb4UCHvsKnylzIYYffLhrNpARoJS5usk+4s= |
| X-Google-Smtp-Source | APXvYqw8C2SCkia8BizluEgnLezu7DsFTkpBS9wI4Oqdc3NuVBfKdsUR3PO/nLTdG2jYdOOSfV2uNmSO83+X5zDYfRE= |
| X-Received | by 2002:a92:7402:: with SMTP id p2mr2451632ilc.64.1580355459115; Wed, 29 Jan 2020 19:37:39 -0800 (PST) |
| In-Reply-To | <20200128210225.GC12574@localhost4.local> |
| X-detected-operating-system | by eggs.gnu.org: Genre and OS details not recognized. |
| X-Received-From | 2607:f8b0:4864:20::12c |
| X-Content-Filtered-By | Mailman/MimeDel 2.1.23 |
| 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 | <CAJnmqwbr6EVJOZn6SLdByAgZAoFN60ahCp3m2HJyJ6VS=hwEvg@mail.gmail.com> |
| X-Mailman-Original-References | <20200128210225.GC12574@localhost4.local> |
| Xref | csiph.com gnu.bash.bug:15851 |
Show key headers only | View raw
On Wed, Jan 29, 2020, 05:02 Roger <rogerx.oss@gmail.com> wrote: > 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... 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
Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread
Re: Preventing Bash Variable Confusion konsolebox <konsolebox@gmail.com> - 2020-01-30 11:37 +0800
csiph-web