Created
July 1, 2011 12:28
-
-
Save nobeans/1058435 to your computer and use it in GitHub Desktop.
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
#!/bin/sh | |
echo $* | |
echo 1: $1 | |
echo 2: $2 | |
echo 3: $3 | |
echo 4: $4 | |
echo 5: $5 | |
echo "-------------------------" | |
function parse_args() { | |
while [ $# -gt 0 ]; do | |
case $1 in | |
*) | |
echo arg: $1 | |
shift | |
;; | |
esac | |
done | |
} | |
parse_args $* | |
echo "-------------------------" | |
echo $* | |
function hoge() { | |
echo HOGE: $* | |
echo 1: $1 | |
echo 2: $2 | |
echo 3: $3 | |
echo 4: $4 | |
echo 5: $5 | |
} | |
hoge $* | |
echo "-------------------------" | |
function escape_only_value() { | |
local TARGET=$1 | |
local FIRSTCHAR=`echo "$TARGET" | sed -e 's/^\(.\).*$/\1/' 2>/dev/null` | |
if [ "$FIRSTCHAR" = "-" ]; then | |
echo "$RESULT $TARGET" | |
else | |
echo "$RESULT \"$TARGET\"" | |
fi | |
} | |
echo $* | |
while [ $# -gt 0 ]; do | |
case $1 in | |
*) | |
echo arg: $1 | |
myargs="$myargs `escape_only_value \"$1\"`" | |
shift | |
;; | |
esac | |
done | |
echo $myargs | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment