![在此示例中,为什么参数扩展发生在大括号扩展之前?](https://linux22.com/image/6598/%E5%9C%A8%E6%AD%A4%E7%A4%BA%E4%BE%8B%E4%B8%AD%EF%BC%8C%E4%B8%BA%E4%BB%80%E4%B9%88%E5%8F%82%E6%95%B0%E6%89%A9%E5%B1%95%E5%8F%91%E7%94%9F%E5%9C%A8%E5%A4%A7%E6%8B%AC%E5%8F%B7%E6%89%A9%E5%B1%95%E4%B9%8B%E5%89%8D%EF%BC%9F.png)
从https://unix.stackexchange.com/a/7739/674,为什么在下面的示例中参数扩展发生在大括号扩展之前?
eval rm foo.{$ext0..$extN}
答案1
它首先进行无操作大括号扩展(扩展到您开始的内容),然后进行参数扩展,然后在“eval”内进行大括号扩展:
# No-op brace expansion example:
echo foo.{not..understood}
# See: foo.{not..understood}
ext0=10
extN=20
# Parameter expansion
echo foo.{$ext0..$extN}
# See: foo.{10..20}
# Final brace expansion
eval echo foo.{$ext0..$extN}
# See: foo.10 foo.11 foo.12 foo.13 foo.14 foo.15 foo.16 foo.17 foo.18 foo.19 foo.20
# Now if you want to have fun with it (each eval unwraps one level of escapes)
eval eval eval eval echo foo.{\\\\\\\$ext0..\\\\\\\$extN}
# See: foo.10 foo.11 foo.12 foo.13 foo.14 foo.15 foo.16 foo.17 foo.18 foo.19 foo.20