aboutsummaryrefslogtreecommitdiff
path: root/bin/wrapper.sh
blob: d29d5b9c074d97812700af84265bc3a7ec2759dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
path_remove () {
    echo $PATH | tr ':' '\n' | grep -v "^$1\$" | tr '\n' ':'
}

PATH="$(path_remove $(dirname $0))"

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"
    exec "$(basename $0)" "$@"
}