for i do echo $i; done
How is this even legal? (I would expect it to be written with an extra semi-colon for i; do echo $i; done
) It works in bash, dash, zsh, and ksh. The standard (by which I mean http://pubs.opengroup.org/onlinepubs/9699919799/) states:
The for loop requires that the reserved words do and done be used to
delimit the sequence of commands. The format for the for loop is as follows:
for name [ in [word ... ]]
do
compound-list
done
So clearly when "in word" is omitted, do
is serving as a separator. So the implication seems to be that the separator (the newline) after the [ in [word .. ]]
actually belongs inside the closing right bracket. Can someone point to anything in the standard which justifies this (IMO) horrible abuse of the language?
So if I remember correctly more people than just me were having problems with a certain make file error stating a missing separator, even if you specifically used tabs and such today I realized all you must do is set your indent type in settings to be tabs instead of spaces and then it should work.
By default, /F breaks up the command output at each blank space, and any blank lines are skipped.
Change Directory - Select a Folder (and drive) Syntax CD [/D] [drive:][path] CD [..] Key /D : change the current DRIVE in addition to changing folder.
2.2 Set/Unset/Change an Environment Variable for the "Current" CMD Session. To set (or change) a environment variable, use command " set varname=value ". There shall be no spaces before and after the '=' sign. To unset an environment variable, use " set varname= ", i.e., set it to an empty string.
If you look at the GNU man
page, you see the loop has this syntax:
for
The syntax of the for command is:
for name [ [in [words …] ] ; ] do commands; done
So as you can see the extra semi-colon is part of the optional section.
The linux-die man page states the same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With