Skip to content

Instantly share code, notes, and snippets.

@codeforkjeff
Created October 3, 2014 02:36
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeforkjeff/79dda02f162ee1f350d9 to your computer and use it in GitHub Desktop.
Save codeforkjeff/79dda02f162ee1f350d9 to your computer and use it in GitHub Desktop.
demo of "set -f" in bash
#!/bin/bash
# run this in a dir with some .zip files
# note that we do NOT escape glob patterns here
opts="-iname *.zip"
# normally, bash will expand *.zip and find will complain about arguments
echo "find will complain:"
find $opts
echo "========================================"
# prevent bash from expanding glob
set -f
echo "find works!"
# this works
find $opts
echo "========================================"
# back to original globbing behavior for remainder of script...
set +f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment