I was recently looking at some code that confused me because it works and I didn't expect it to. The code reduces to this example
#!/bin/bash
for var;
do
echo "$var"
done
When run with command line arguments is prints them
$ ./test a b c
a
b
c
It is this, that is (to me) unexpected. Why does this not result in an error because var
is undefined ? Is using this considered 'good practice' ?