I'm aware of how to get the last argument passed to a function but I'm wondering how to get all the arguments of a function after the first two:
For instance:
function custom_scp(){
PORT=$1
USER=$2
SOURCES=`ALL_OTHER_ARGS`
scp -P $PORT -r $SOURCES [email protected]:~/
}
So sending three files to the remote home
directory would look like
$ custom_scp 8001 me ./env.py ./test.py ./haha.py
function foo() {
is mixing POSIX sh and ksh function declaration formats in a way that's compatible with neither POSIX sh nor with legacy ksh. Pick one or the other:foo() {
is the POSIX form,function foo {
is the ksh form.USER
, for example, is a reserved variable name. By overwriting it, you're potentially breaking other commands run later in the same session. See pubs.opengroup.org/onlinepubs/9699919799/basedefs/… -- all-caps names are used for variables that modify system behavior, lower-case names are reserved for application use. Setting a shell variable with the same name as an environment variable overwrites the latter, so the namespace rules apply to both sets.