From c35b4a0846ea9867ed1eeea94a465019a22b6b6c Mon Sep 17 00:00:00 2001 From: Chris Larson Date: Thu, 4 Nov 2010 11:21:38 -0700 Subject: bin/{cp,sed}: simplify, consolidate Signed-off-by: Chris Larson --- bin/wrapper.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 bin/wrapper.sh (limited to 'bin/wrapper.sh') diff --git a/bin/wrapper.sh b/bin/wrapper.sh new file mode 100644 index 0000000000..3a93475b7f --- /dev/null +++ b/bin/wrapper.sh @@ -0,0 +1,29 @@ +path_remove () { + echo $PATH | tr ':' '\n' | grep -v "^$1\$" | tr '\n' ':' +} + +quote(){ + sed -e "s,','\\\\'',g; 1s,^,',; \$s,\$,',;" << EOF +$1 +EOF +} + +save () { + case "$1" in + # when a string contains a "'" we have to escape it + *\'*) + saved="$saved $(quote "$1")" + ;; + # otherwise just quote the variable + *) + saved="$saved '$1'" + ;; + esac +} + +exec_real () { + eval set -- "$saved" + scriptdir="$(dirname $0)" + PATH="$(path_remove $scriptdir)" + exec "$(basename $0)" "$@" +} -- cgit 1.2.3-korg