Skip to content

Instantly share code, notes, and snippets.

@oneyoung
Created June 24, 2014 07:49
Show Gist options
  • Save oneyoung/88be5e3f0004875946b1 to your computer and use it in GitHub Desktop.
Save oneyoung/88be5e3f0004875946b1 to your computer and use it in GitHub Desktop.
A example to reserve quotes and passing to sub-function.
# 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