Created
November 22, 2022 01:18
-
-
Save pgreze/6cae3749c56c4d690d825682547b7718 to your computer and use it in GitHub Desktop.
How to forward well bash arguments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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