Path: csiph.com!au2pb.net!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!news.glorb.com!usenet.stanford.edu!not-for-mail From: Linda Walsh Newsgroups: gnu.bash.bug Subject: minor language RFE(s) Date: Wed, 07 Oct 2015 16:38:23 -0700 Lines: 69 Approved: bug-bash@gnu.org Message-ID: NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: usenet.stanford.edu 1444261121 19573 208.118.235.17 (7 Oct 2015 23:38:41 GMT) X-Complaints-To: action@cs.stanford.edu To: bug-bash Envelope-to: bug-bash@gnu.org User-Agent: Thunderbird X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 173.164.175.65 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:11584 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, 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 --- Note: "int" and "my" would be equivalent to "declare -i" and "declare" -- NOT "local -i" or "local" so that such statements could be moved in or out of functions w/out removing the declaration. Note2: 'my' is for convenience -- so one wouldn't have to spell out for declare i in {a..z}... which looks a bit ugly IMO... Anyway was just thinking about this when writing such loops, and renaming the iterator a few times -- and having to make sure the declaration was changed in line with the 'for' usage: requiring 2 separate lines of code (that may or may not be adjacent to each other) in sync is always a pain, not to mention occasionally error prone. Anyway -- just a thought? I've no idea of the difficulty level to do this, but was thinking if not too difficult... and if it is... well keep it on a pile of ideas if bash ever got refactored such that implementation became easier..?