Say I create a file ~/myScript.sh:
#!/bin/sh
for myVar; do
echo "Hi"
done
If I execute bash myScript with no arguments I'll get nothing but if I'll execute it with one or more arguments I'll get the output per the number of these variables (the variable seems to make the script dependent in passed arguments):
bash ~/myScript.sh arg0 arg1
The for loop, which is based on the undefined variable myVar, would apply arg0 and arg1 to itself (sorry if this phrasing is lousy) and I'll get this output:
Hi
Hi
(one "Hi" per argument).
I originally assumed that one for loop works with one argument so if I would have myVar_0 and myVar_1 with arg0 and arg1, then myVar_0 will work with arg_0 and myVar_1 will work with arg1 but I further tested and I was wrong --- all for loops worked with all arguments:
#!/bin/sh
for myVar_0; do
echo "Hi"
done
for myVar_1; do
echo "Hello"
done
will return in bash myScript arg0 arg1:
Hi
hello
Hi
hello
Sidenote: I assume that if would want "1 argument per 1 for loop" I just need to use a Bash function for local scope.
My question
What is the name of this "all arguments per all for loops" matching that Bash does?