On 04/21/2015 01:44 PM, Dr Alun J. Carr wrote: > Tests were done with bash, ksh, zsh, pdksh, dash and heirloom System V Bourne > sh with the following versions: > bash 3.2.57(1) > bash 4.3.33(1) > ksh version sh (AT&T Research) 93u+ 2012-08-01 > zsh 5.0.5 (x86_64-apple-darwin14.0) > pdksh stable 5.2.14 > dash stable 0.5.8 > sh ???
You do realize, I hope, that brace expansion is not required by POSIX, and therefore there is no standard for what behavior it has, and it should be no surprise that pdksh, dash, and Bourne sh do not try to expand it. As for whether bash should expand $n into 4 prior to doing brace expansion, or whether brace expansion is attempted first but not recognizing $n as a valid bound devolves into no expansion, that is indeed a difference between ksh and bash. But bash is consistent with its documentation: > The order of expansions is: brace expansion; tilde expansion, parameter > and variable expansion, arithmetic expansion, and command substitution > (done in a left-to-right fashion); word splitting; and pathname expanâ > sion. so you cannot use a variable as a bound and still expect brace expansion to work, since variables aren't expanded yet. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature