Skip to content

Instantly share code, notes, and snippets.

@pgreze
Created November 22, 2022 01:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pgreze/6cae3749c56c4d690d825682547b7718 to your computer and use it in GitHub Desktop.
Save pgreze/6cae3749c56c4d690d825682547b7718 to your computer and use it in GitHub Desktop.
How to forward well bash arguments
$ cat args.sh
pargs() { echo "arg1=$1 arg2=$2"; }
pargs "$@"
pargs "$*"
$ sh ./args.sh "Hello world" haha
arg1=Hello world arg2=haha
arg1=Hello world haha arg2=
$ cat forward.sh
command() { echo "arg1=$1 arg2=$2"; }
forward() { command "$@"; } # Helpful considering script does not support aliases
forward "Hello world" haha
$ sh ./forward.sh
arg1=Hello world arg2=haha
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment