Created
November 15, 2018 22:00
-
-
Save mitsu-ksgr/d49c2407f8a55ed799b164a8c2da14dc to your computer and use it in GitHub Desktop.
bash shift example
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 characters
| #!/bin/sh | |
| set -e | |
| #------------------------------------------------------------------------------ | |
| # shift sample | |
| # | |
| # | |
| # $ ./shift.sh a b c [shell] | |
| # > ARGV: 3, ARGS: [a b c], Shifted: [b c] | |
| # > ARGV: 2, ARGS: [b c], Shifted: [c] | |
| # > ARGV: 1, ARGS: [c], Shifted: [] | |
| # > ARGV: 0, ARGS: [], finish! | |
| #------------------------------------------------------------------------------ | |
| echo -n "ARGV: $#, ARGS: [$*]" | |
| if [ -z "$1" ]; then | |
| echo ", finish!" | |
| else | |
| shift | |
| echo ", Shifted: [$*]" | |
| . ./test.sh $* | |
| fi | |
| exit 0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment