Skip to content

Instantly share code, notes, and snippets.

@nobeans
Created July 1, 2011 12:28
Show Gist options
  • Save nobeans/1058435 to your computer and use it in GitHub Desktop.
Save nobeans/1058435 to your computer and use it in GitHub Desktop.
#!/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