Many questions about part of a shell script generated by autoconf Many questions about part of a shell script generated by autoconf shell shell

Many questions about part of a shell script generated by autoconf


From Bash man page:

{ list; } list is simply executed in the current shell environment. list must be terminated with a newline or semicolon. This is known as a group command. The return status is the exit status of list. Note that unlike the metacharacters ( and ), { and } are reserved words and must occur where a reserved word is permitted to be recognized. Since they do not cause a word break, they must be separated from list by whitespace or another shell metacharacter.

{} is just to list a few commands to run, very much like cmd1; cmd2; cmd3. For example, if you write cmd1 ; cmd2 | cmd3, do you mean {cmd1; cmd2;} | cmd3 or cmd1; {cmd2 | cmd3;}.

{{ }} is just nested command list, easy: e.g. {cmd1; cmd2; {cmd3; cmd4;}; }

For question 3, (( is just in a source string to be matched with the following patterns. If you are asking why it is used, we need possible values of $ac_try to analyze why. Honestly, I don't see many shell scripts purposely adding (( in front of a source string to be matched for patterns.

For question 4,>&5: if file descriptor 5 is not yet created (i.e. mentioned in any part of the script... => be careful, you need to care the scope, some codes runs in sub-shell, which is counted as a sub-shell context/scope), create an unnamed file (well, temp file, if you like), with descriptor 5. This file can be used in other part of the script as an input.

For example, see the part mentioning "exchanges STDIN and STDOUT" in my answer to another question here.

For question 5, the eval, I am not quite sure, just a quick guess (and it depends on what command it evals) by providing you an example why sub-shell makes some differences:

cmd="Foo=1; ls"(eval $cmd)   # this command runs in sub-shell and thus $Foo in current shell will not be changed.eval $cmd     # this command runs in current shell and thus $Foo is changed, and it will affect all subsequent commands.

For question 6, look carefully at the man page I mentioned at top of the answer, the {} list syntax, require a final ;. i.e. {cmd1; cmd2 ; } The last ; is required.

--- UPDATE ---

Question 6: Sorry for not seeing the colon... :-)It's no op: see this link.