I don't understand this behavior that the BASH_ARGV variable has in these two scripts.
First sript ./dd.stackoverflow.sh:
#!/bin/bash
existArg() {
echo "Args#: ${#BASH_ARGV[@]}"
}
existArg
Execución:
./dd.stackoverflow.sh hello1 hello2 hello3 hello4 hello5 hello6 hello7
Result:
Args#: 0
Second script dd.stackoverflow2.sh:
#!/bin/bash
echo "${#BASH_ARGV}" > /dev/null
existArg() {
echo "Args#: ${#BASH_ARGV[@]}"
}
existArg
Execution:
./dd.stackoverflow2.sh hello1 hello2 hello3 hello4 hello5 hello6 hello7
Result:
Args#: 7
I also don't understand why the result is not consistent in both scripts.
Please, can someone explain this to me?