On Saturday, May 10, 2014 02:35:44 PM NBaH wrote: > bash-4.2 $ printf "%s " "$(date -d -"{0..9}"days +%Y%m%d)" 20140510 > 20140509 20140508 20140507 20140506 20140505 20140504 20140503 > 20140502 20140501 > > bash-4.3 $ printf "%s " "$(date -d -"{0..9}"days +%Y%m%d)" date: date > non valide « -{0..9}days »
This was a bug. Chet fixed it for 4.3. The inner brace expansion should not be evaluated because (non-backtick) command substitutions always produce a completely new context for evaluating commands. Since bash re-arranges Csh brace expansion to be first, it has to heuristically protect the applicable expansions that happen later from its effects. That's a hard problem. You can achieve the same effect in other ways by looping or with eval if appropriate. printf %()T is another possibility. I usually abuse the way Bash parses array subscripts. If ksh93 is available then a simpler solution is possible. $ bash -c 'printf -v a "%(%s)T" -1; printf "%(%Y%m%d)T " "$a" "${a[a+=60*60*24,0]"{0..8}"}"; echo' 20140510 20140511 20140512 20140513 20140514 20140515 20140516 20140517 20140518 20140519 $ ksh -c 'printf "%(%Y%m%d)T " "" -{1..9}\ days; echo' 20140510 20140511 20140512 20140513 20140514 20140515 20140516 20140517 20140518 20140519 -- Dan Douglas