As passing arguments to a self made script, I noted they got evaluated by the file-system if that mach, otherwise, just passed as argument. And that is not the behaviour I'm hopping for
giving that code
#!/bin/bash
declare -a array_arg
#build the array of arguments
while test -n "$1"; do array_arg+=( "$1" ); shift
done
#test there is some arguments
if test ${#array_arg[@]} -eq 0; then echo "ERROR no arguments"
fi
#running resume
echo "number of elements:: ${#array_arg[@]}"
for ((i = 0; i < ${#array_arg[@]}; i++ )); do echo "$i>> ${array_arg[i]}"
done
I will expect that same list of arguments I pass, I will have into the array_arg array
but, if any argument has a wildcard, and match a file, it get resolve with the name of the file/s
lets see an example :
let's observe, the second argument
file2*
how in the instruction
array_arg+=( "$1" )
adds two filenames to the array, instead of the value of $1
while the last argument, do not get changed/resolved/whatever...
Needless to say, I need the arguments as passed to the script, not evaluated