Created
October 3, 2014 02:36
-
-
Save codeforkjeff/79dda02f162ee1f350d9 to your computer and use it in GitHub Desktop.
demo of "set -f" in bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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