Last active
August 16, 2018 17:27
-
-
Save nanpuyue/04f4a9e19d9543dccd26103de9bddd00 to your computer and use it in GitHub Desktop.
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/bash | |
| # file: args.sh | |
| # date: 2018-08-17 | |
| # license: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt | |
| # author: nanpuyue <[email protected]> https://blog.nanpuyue.com | |
| LIST=(1 ' 2 3') | |
| at(){ | |
| for i in $@; do | |
| echo "$i" | |
| done | |
| } | |
| at_q(){ | |
| for i in "$@"; do | |
| echo "$i" | |
| done | |
| } | |
| star(){ | |
| for i in $*; do | |
| echo "$i" | |
| done | |
| } | |
| star_q(){ | |
| for i in "$*"; do | |
| echo "$i" | |
| done | |
| } | |
| do_eval(){ | |
| echo $1 $2 | |
| echo ---------- | |
| eval printf '"%q\n"' $2 | |
| echo ---------- | |
| eval $1 $2 | |
| echo ==================== | |
| } | |
| if [ "$1" = '-q' ]; then | |
| for f in at_q star_q; do | |
| for a in '"${LIST[@]}"' '"${LIST[*]}"'; do | |
| do_eval $f $a | |
| done | |
| done | |
| else | |
| for f in at at_q star star_q; do | |
| for a in '"${LIST[@]}"' '"${LIST[*]}"' '${LIST[@]}' '${LIST[*]}'; do | |
| do_eval $f $a | |
| done | |
| done | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment