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


Groups > gnu.bash.bug > #16731

Re: Undocumented for-loop construct

From Chet Ramey <chet.ramey@case.edu>
Newsgroups gnu.bash.bug
Subject Re: Undocumented for-loop construct
Date 2020-08-07 09:29 -0400
Organization ITS, Case Western Reserve University
Message-ID <mailman.1133.1596806985.2739.bug-bash@gnu.org> (permalink)
References <CAGqdar04i1z28vYUFuGr=7WZOUsar8JE+QW0TAm1bnP0+DtEjQ@mail.gmail.com> <54462ce1-d88e-4551-aba3-dbf7d371be8a@case.edu>

Show all headers | View raw


On 8/6/20 5:50 PM, Klaas Vantournhout wrote:
> Dear Bash-developers,
> 
> Recently I came across a surprising undocumented bash-feature
> 
>    $ for i in 1 2 3; { echo $i; };
> 
> The usage of curly-braces instead of the well-documented do ... done
> construct was a complete surprise to me and even lead me to open the
> following question on stack overflow:
> 
> 
> https://stackoverflow.com/questions/63247449/alternate-for-loop-construct
> 
> The community is unable to find any reference to this feature, except
> 
> * a brief slide in some youtube presentation by Stephen Bourne:
> 
>     https://www.youtube.com/watch?v=2kEJoWfobpA&t=2095
>     Relevant part starts at 34:55
> 
> * and the actual source code of bash and the Bourne Shell V7

It's never been documented. The reason bash supports it (undocumented) is
because it was an undocumented Bourne shell feature that we implemented
for compatibility. At the time, 30+ years ago, there were scripts that used
it. I hope those scripts have gone into the dustbin of history, but who
knows how many are using this construct now.

I'm going to leave it undocumented; people should not be using it anyway.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

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


Thread

Re: Undocumented for-loop construct Chet Ramey <chet.ramey@case.edu> - 2020-08-07 09:29 -0400

csiph-web