|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
For x in a b c; { list; } (in lieu of do list; done) works (in bash) - why and how?
In this post I came across the cited construct. It works!
while ... { list; } does not.
man bash does not mention it (or, better, I didn't see it). Any reason for / behind this? Am I missing something? |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
how about f() without braces? Code:
mute@clt:~$ f() for x in 1 2 3; { echo $x; };
mute@clt:~$ f
1
2
3implementation. somehow for got away with accepting a list, but while didn't. I would not rely on it, but it has saved me a few bytes with code golfing
|
| Sponsored Links | ||
|
|
#3
|
||||
|
||||
|
I think this undocumented syntax is still there for historical reasons and should not be used. I noticed it works in both old and new bash versions. It also works in zsh and ksh93, but not in ksh88. It is not POSIX compliant and does not work in dash.
|
|
#4
|
|||
|
|||
|
Shells with that type of for-loop support typically also support an analogous
select statement:
select i in a b c; { echo $i; }
I have never used either myself. I see no benefit, only headaches. Regards, Alister |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Quote:
An application could be a POSIX conforming application using extensions if it documented that it needed a shell that supports this syntax and otherwise used only features documented by the POSIX standards. Otherwise, as far as the standards are concerned, the behavior of an application using syntax that is not documented by the standard is unspecified. |
| Sponsored Links | |
|
|
#6
|
||||
|
||||
I like it when you're being picky. With "It is not .." , I meant "The use of these features is not.." |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Take a list if strings from a file and search them in a list of files and report them | realspirituals | Shell Programming and Scripting | 8 | 10-13-2011 06:37 AM |
| find list of files from a list and copy to a directory | manishabh | Shell Programming and Scripting | 3 | 09-13-2009 06:03 PM |
| Splitting a list @list by space delimiter so i can access it by using $list[0 ..1..2] | shriyer | Shell Programming and Scripting | 1 | 07-29-2009 02:05 PM |
| Make a list in bash out of arguments | jolecanard | Shell Programming and Scripting | 4 | 07-02-2009 04:23 PM |
| [bash]Stripping lines from a list | noratx | UNIX for Dummies Questions & Answers | 8 | 04-04-2008 02:38 AM |
|
|