Skip to main content
added 584 characters in body
Source Link
glenn jackman
  • 88.6k
  • 16
  • 124
  • 180

The bash manual has this to say in the 3.6 Redirections section:

The word following the redirection operator in the following descriptions, unless otherwise noted, is subjected to brace expansion, tilde expansion, parameter expansion, command substitution, arithmetic expansion, quote removal, filename expansion, and word splitting. If it expands to more than one word, Bash reports an error.

sh does not do that;that: from the POSIX shell specification

If the redirection operator is "<<" or "<<-", [...]. For the other redirection operators, the word that follows the redirection operator shall be subjected to tilde expansion, parameter expansion, command substitution, arithmetic expansion, and quote removal. Pathname expansion shall not be performed on the word by a non-interactive shell; an interactive shell may perform it, but shall do so only when the expansion would result in one word.

$ dash $ echo foo > * $ ls '*' README.md ... 
$ bash $ echo bar >> * bash: *: ambiguous redirect 

The bash manual has this to say in the 3.6 Redirections section:

The word following the redirection operator in the following descriptions, unless otherwise noted, is subjected to brace expansion, tilde expansion, parameter expansion, command substitution, arithmetic expansion, quote removal, filename expansion, and word splitting. If it expands to more than one word, Bash reports an error.

sh does not do that;

$ dash $ echo foo > * $ ls '*' README.md ... 
$ bash $ echo bar >> * bash: *: ambiguous redirect 

The bash manual has this to say in the 3.6 Redirections section:

The word following the redirection operator in the following descriptions, unless otherwise noted, is subjected to brace expansion, tilde expansion, parameter expansion, command substitution, arithmetic expansion, quote removal, filename expansion, and word splitting. If it expands to more than one word, Bash reports an error.

sh does not do that: from the POSIX shell specification

If the redirection operator is "<<" or "<<-", [...]. For the other redirection operators, the word that follows the redirection operator shall be subjected to tilde expansion, parameter expansion, command substitution, arithmetic expansion, and quote removal. Pathname expansion shall not be performed on the word by a non-interactive shell; an interactive shell may perform it, but shall do so only when the expansion would result in one word.

$ dash $ echo foo > * $ ls '*' README.md ... 
$ bash $ echo bar >> * bash: *: ambiguous redirect 
Post Made Community Wiki
Source Link
glenn jackman
  • 88.6k
  • 16
  • 124
  • 180

The bash manual has this to say in the 3.6 Redirections section:

The word following the redirection operator in the following descriptions, unless otherwise noted, is subjected to brace expansion, tilde expansion, parameter expansion, command substitution, arithmetic expansion, quote removal, filename expansion, and word splitting. If it expands to more than one word, Bash reports an error.

sh does not do that;

$ dash $ echo foo > * $ ls '*' README.md ... 
$ bash $ echo bar >> * bash: *: ambiguous redirect