This is the mail archive of the
mailing list for the glibc project.
Re: [PATCH] Avoid busy loop in wordexp when substituted command closedits stdout
On 01/21/2013 11:10 AM, Andreas Schwab wrote:
> Carlos O'Donell <email@example.com> writes:
>> I wondered if your example in #15020 was valid given the restrictions
>> placed upon wordexp by POSIX,
> Which restrictions?
The words argument is a pointer to a string containing one or more words to be expanded. The expansions shall be the same as would be performed by the command line interpreter if words were the part of a command line representing the arguments to a utility. Therefore, the application shall ensure that words does not contain an unquoted <newline> character or any of the unquoted shell special characters '|' , '&' , ';' , '<' , '>' except in the context of command substitution as specified in XCU Command Substitution . It also shall not contain unquoted parentheses or braces, except in the context of command or variable substitution. The application shall ensure that every member of words which it expects to have expanded by wordexp() does not contain an unquoted initial comment character. The application shall also ensure that any words which it intends to be ignored (because they begin or continue a comment) are deleted from words. If the argument words contains an unquoted comment ch
aracter ( <number-sign>) that is the beginning of a token, wordexp() shall either treat the comment character as a regular character, or interpret it as a comment indicator and ignore the remainder of words.
With the $( command) form, all characters following the open parenthesis to the matching closing parenthesis constitute the command. Any valid shell script can be used for command, except a script consisting solely of redirections which produces unspecified results.
Which is what convinced me that "$(exec >&-; sleep 10)" is valid input to wordexp.
Any valid shell script can be used, and your example does not consist solely of redirections.