Related: Stop shell wildcard character expansion?
I had in the past used set -f
in bash to prevent glob expansion - however this seems to not work on my mac any more:
$ cat script.sh
#!/bin/bash
echo $0
i=1
for var in $@
do
echo "$i => $var"
((i++))
done
$ set -f
$ ./script.sh *
./script.sh
1 => program
2 => program.cpp
3 => script.sh
With the set -f
I expected the output to be
$ ./script.sh *
./script.sh
1 => *
What am I missing and how can I stop the expansion.