Is there an easy way to set nullglob for one glob
问题 In bash, if you do this: mkdir /tmp/empty array=(/tmp/empty/*) you find that array now has one element, "/tmp/empty/*" , not zero as you'd like. Thankfully, this can be avoided by turning on the nullglob shell option using shopt -s nullglob But nullglob is global, and when editing an existing shell script, may break things (e.g., did someone check the exit code of ls foo* to check if there are files named starting with "foo"?). So, ideally, I'd like to turn it on only for a small scope