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


Groups > gnu.bash.bug > #11680

Re: language inconsistency(wart) & RFE

Path csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!usenet.stanford.edu!not-for-mail
From isabella parakiss <izaberina@gmail.com>
Newsgroups gnu.bash.bug
Subject Re: language inconsistency(wart) & RFE
Date Sat, 17 Oct 2015 07:00:25 +0200
Lines 94
Approved bug-bash@gnu.org
Message-ID <mailman.495.1445058030.7904.bug-bash@gnu.org> (permalink)
References <5621A1DD.90205@tlinx.org>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace usenet.stanford.edu 1445058031 32625 208.118.235.17 (17 Oct 2015 05:00:31 GMT)
X-Complaints-To action@cs.stanford.edu
Cc bug-bash <bug-bash@gnu.org>
To Linda Walsh <bash@tlinx.org>
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=GPXPKkLCA5s+lzVCMe5c29EgDcmrIVpRvWpqOSF7tcs=; b=MxR+JABXrZM9lsG7R3KSXmkaGqggBehB6EUn3G3Hg6wqTUsvt4CWuIKSNmZG0yCfSb rZ3jkAaN+C6YIdqysk739h/KgfyKV5LO/198hyq2QmJUeWcFIHfokX3OYcfRbf8Rojnm /dQCMPQXfGgA081WYu5eXWVylOb9wVRIHmpJGZ3HwB/P8EcG+WsWRPvfSznW7ZISqiUM sibJbAaC6bg54JOvUJr5Y6YjA3kcS/dIfFVatZBcifH62YDjoKs8FHE7HMuwLcYfozlq qg94KHeWyYQM4U2nL2xmJL+fsjbnJb1f9IgWk3YFD2gGBvoF+hZ2jrQhJvfiCrob0EN5 WgYQ==
X-Received by 10.107.10.210 with SMTP id 79mr1130634iok.31.1445058025693; Fri, 16 Oct 2015 22:00:25 -0700 (PDT)
In-Reply-To <5621A1DD.90205@tlinx.org>
X-detected-operating-system by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value).
X-Received-From 2607:f8b0:4001:c06::234
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.14
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 <http://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>
Xref csiph.com gnu.bash.bug:11680

Show key headers only | View raw


On 10/17/15, Linda Walsh <bash@tlinx.org> wrote:
> Ok, thinking this from a different way.
>
> shopt -s implicit_vars_local
> or
> shopt -s localize_func_implicit_vars.... whatever...
>
> Right now, in a function, you *can* use local in a function
> to make a local var.  Thing is, both 'declare' and 'typeset' also
> make a *local* var in a function, unless the "-g" switch is used.
>
> I.e. All standard, overt ways (local declare typeset) of creating
> a var in a function all result in it being local, BUT,
> (and I think this is an ugly wart),
> any *implicit vars* without local, or the
> misleading declare or typeset, become global.
>
> examples:  In these two for statements, used in functions, 'i'
> becomes global:
>
>   for((i=0; i<10; ++i)); do : done
>   for i in {1..10}; do : done
>
> And same with 'myarray':
>   readarray myarray=$(echo "one";echo "two")
>
> and reads and assignments, and 'lets'
>   read ln < <(echo "one"; echo "two")
>   ln2="one two"
>   read ln3 <<< "one two"
>
> but if this isn't a potential for confusion:
>
>> function aa {
> read ln < <(echo "one"; echo "two")
> ln2="12"
> read ln3 <<< "one two"
> ar1=(one two)
> typeset -i ln2=34
> typeset -a ar1=(three four)
> }
>> whence aa
> aa is a function
> aa ()
> {
>     read ln < <(echo "one"; echo "two");
>     ln2="12";
>     read ln3 <<< "one two";
>     ar1=(one two);
>     typeset -i ln2=34;
>     typeset -a ar1=(three four)
> }
>> aa
>> declare -p ln ln2 ln3 ar1
> declare -- ln="one"
> declare -- ln2="12"
> declare -- ln3="one two"
> declare -a ar1='([0]="one" [1]="two")'
>
> !!!  -- sure looks like I was trying to set the "type" of ln2
> and ar1... boy could that be confusing...
>
> ....
> So, how about a "shopt"
> to declare that **what's implicity declared in funcs, stays in funcs**
> maybe shopt -s vegasvars ?.....
>
> but seriously -- it's so odd that anything you declare explicitly
> becomes local, while implicit vars default to global --
> I know standards and compat must keep it that way... BUT
> it would have made more sense to have
> implicit vars in a function always be 'local'
> and maybe have explicit declarators be global
> (which has effectively been done with -g)...but
> originally, I also thought it strange that 'declare/typeset'
> were equivalent to 'local' inside a function.
>
> This way, you wouldn't have to change any syntax
> parsing functions and there certain isn't ANYTHING
> that would look like perl, even though perl was
> originally designed to be like shell with many shell standard
> functions built-in.
>
> ???
>
>
>

Maybe you can just use this?    alias declare='declare -g'


---
xoxo iza

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


Thread

Re: language inconsistency(wart) & RFE isabella parakiss <izaberina@gmail.com> - 2015-10-17 07:00 +0200

csiph-web