diff options
Diffstat (limited to 'bin/wrapper.sh')
-rw-r--r-- | bin/wrapper.sh | 29 |
1 files changed, 29 insertions, 0 deletions
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)" "$@" +} |