Created
June 24, 2014 07:49
-
-
Save oneyoung/88be5e3f0004875946b1 to your computer and use it in GitHub Desktop.
A example to reserve quotes and passing to sub-function.
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
# keep quotes in args | |
# http://stackoverflow.com/questions/1668649/how-to-keep-quotes-in-args | |
whitespace="[[:space:]]" | |
for i in "$@" | |
do | |
if [[ $i =~ $whitespace ]] | |
then | |
i=\"$i\" | |
fi | |
cmd="$cmd $i" | |
done | |
export GREP_OPTIONS='--color=always' | |
function run() { | |
echo "######" $1 | |
cd $1 | |
# execute the command use "bash -c" | |
bash -c "$cmd" | |
cd - > /dev/null | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment