Hacker News new | past | comments | ask | show | jobs | submit login

I didn't know {} could nest!



It sorta can't... note the use of eval.


The eval isn't to help with the nesting. The {} stuff nests just fine, as we can see by changing the "eval mv" to printf:

  $ printf '[%s]' file{,{.bak\;mv,.new},}
  [file][file.bak;mv][file.new][file]
(Note: I took out the '\ ' from the original because I realized it is not necessary).

The eval is there because in bash text expansion occurs after ';' is interpreted, and we need that to be the other way around. Hence, the escaping of ';' in the input to preserve it for text expansion, and then the eval afterward to get ';' interpreted.


Sorry, I should have checked.

I jumped at it because there are other things one might like to achieve with brace expansion but turn out to be impossible because it is evaluated first - you can't use them with variables.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: