I have a bash script that is writing out a file to /usr/local/bin that needs to take in additional parameters.
I'm trying something like this:
echo "PYTHONPATH=/opt/script_folder/$TIMESTAMP /opt/script_folder/$TIMESTAMP/script -param <param_value> $@" | sudo tee /usr/local/bin/script_alias
I want the user to be able to use this by running script_alias -second_param <second_value> ... and the script picking up the second parameter.
However, the $@ is pulling in every param I pass to the shell script writing out the /usr/local/bin file. I tried escaping the $ to \$@ but the $@ is not being written out. Any thoughts on why?
"$@"or"$1"or any other reference to command-line arguments in an alias, you're not referring to the arguments that the alias was passed, but the arguments that were already set before you called the alias; the alias doesn't have its own stack frame, so it doesn't have its own argument list).args=( "$@" )will store your current argument list into an array, so you can have a function have its own argument list but be able to refer back to that array. BTW, aliases don't work in scripts at all.