-
-
Save sethbergman/1fb0e343dbc97c2213fdac6da00249c6 to your computer and use it in GitHub Desktop.
Revisions
-
awwsmm revised this gist
Jun 21, 2019 . 1 changed file with 12 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,19 @@ #!/usr/bin/env bash #------------------------------------------------------------------------------- # # print_args - easily inspect arguments passed to a bash script # # sources: # https://unix.stackexchange.com/a/332126/183920 # #------------------------------------------------------------------------------- function print_args { echo "arguments:" local ii=1 for arg; do printf " \$%u: '%s'\n" "$ii" "$arg" ((ii++)) @@ -14,7 +23,7 @@ function printargs { # usage: # # $ print_args 3 "3.a" "hello world" # arguments: # $1: '3' # $2: '3.a' -
awwsmm revised this gist
Jun 21, 2019 . 1 changed file with 18 additions and 15 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,36 +4,39 @@ function printargs { echo "arguments:" ii=1 for arg; do printf " \$%u: '%s'\n" "$ii" "$arg" ((ii++)) done } # usage: # # $ printargs 3 "3.a" "hello world" # arguments: # $1: '3' # $2: '3.a' # $3: 'hello world' function example { echo "printing arguments passed to 'example'..." printargs "$@" echo "...done." printf "\$2 = %s\n" "$2" } # example: # # $ example "a b" 5.5 ho-ho # printing arguments passed to 'example'... # arguments: # $1: 'a b' # $2: '5.5' # $3: 'ho-ho' # ...done. # $2 = 5.5 -
awwsmm created this gist
Jun 21, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ #!/usr/bin/env bash function printargs { echo "arguments:" ii=0 for arg; do printf " %u: '%s'\n" "$ii" "$arg" ((ii++)) done } # usage: # # $ source ex.sh # $ printargs a b c # arguments: # 0: 'a' # 1: 'b' # 2: 'c' function another { echo "printing arguments passed to 'another'..." printargs "$@" echo "...done." } # example: # $ another "g h" 1 # printing arguments passed to 'another'... # arguments: # 0: '' # 1: 'g h' # 2: '1' # ...done.