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


Groups > gnu.bash.bug > #11586

Re: minor language RFE(s)

Path csiph.com!au2pb.net!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!news.glorb.com!usenet.stanford.edu!not-for-mail
From Andreas Schwab <schwab@suse.de>
Newsgroups gnu.bash.bug
Subject Re: minor language RFE(s)
Date Thu, 08 Oct 2015 10:07:15 +0200
Lines 51
Approved bug-bash@gnu.org
Message-ID <mailman.3.1444291696.4386.bug-bash@gnu.org> (permalink)
References <5615ACEF.4040804@tlinx.org>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain
X-Trace usenet.stanford.edu 1444291696 5895 208.118.235.17 (8 Oct 2015 08:08:16 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
X-Virus-Scanned by amavisd-new at test-mx.suse.de
X-Yow Yow! I like my new DENTIST...
In-Reply-To <5615ACEF.4040804@tlinx.org> (Linda Walsh's message of "Wed, 07 Oct 2015 16:38:23 -0700")
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
X-detected-operating-system by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic]
X-Received-From 195.135.220.15
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:11586

Show key headers only | View raw


Linda Walsh <bash@tlinx.org> writes:

> If I am using a var as an index in a for loop
> as in:
>
>   for((i=0; i<10; ++i)); do : done
>
> or 2) as an iterator as in
>
>   for i in {1..10}; do : done
>
> **and** such usage is in a function,
>
> the default is to promote 'i' to 'global' status,

This behaviour is shared with all uses of shell variables.

> which is usually not needed nor desired (that doesn't mean
> there aren't cases where one wants it global,
> but I'm referring to the most common case).
>
> The common workaround is to put the onus on the user
> of 'i' to first declare it as local.  That's not easily
> changed w/o potential chaos... however,
>
> I was thinking ... lets say we had 1 or 2 abbreviation
> keywords, at least 1 being "int=declare -i",
> and ease-of-use "my=declare"
>
> that could then allow the "declare" of the 'for' iterator
> as local, in-line.
>
> i.e. instead of predeclaring them w/'declare -i' or 'declare'
> one could write:
>
>   for((int i=0; i<10; ++i)); do : done
>
> or 2)
>
>   for int i in {1..10}; do : done
>   for my i in {a..z}; do : done

If you want perl you know where to get it.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

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


Thread

Re: minor language RFE(s) Andreas Schwab <schwab@suse.de> - 2015-10-08 10:07 +0200

csiph-web