diff options
author | Chris Larson <chris_larson@mentor.com> | 2010-11-04 11:21:38 -0700 |
---|---|---|
committer | Chris Larson <chris_larson@mentor.com> | 2010-11-04 11:21:38 -0700 |
commit | c35b4a0846ea9867ed1eeea94a465019a22b6b6c (patch) | |
tree | ccc8da121f37eaf854900396015d0e37f118304c /bin/wrapper.sh | |
parent | 3620e5ee5e3e32b592c949b18d2fc06f58024590 (diff) | |
download | openembedded-c35b4a0846ea9867ed1eeea94a465019a22b6b6c.tar.gz |
bin/{cp,sed}: simplify, consolidate
Signed-off-by: Chris Larson <chris_larson@mentor.com>
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)" "$@" +} |