#!/bin/sh -f

makeAbsolute() {
    case $1 in
        /*)
            # already absolute, return it
            echo "$1"
            ;;
        *)
            # relative, prepend $2 made absolute
            echo `makeAbsolute "$2" "$PWD"`/"$1" | sed 's,/\.$,,'
            ;;
    esac
}

me=`which "$0"` # Search $PATH if necessary
# if it's a symbolic link, get path of destination
if test -L "$me"; then
    # Try readlink(1)
    readlink=`type readlink 2>/dev/null` || readlink=
    if test -n "$readlink"; then
        # We have readlink(1), so we can use it. Assuming GNU readlink (for -f).
        me=`readlink -nf "$me"`
    else
        # No readlink(1), so let's try ls -l
        me=`ls -l "$me" | sed 's/^.*-> //'`
        base=`dirname "$me"`
        me=`makeAbsolute "$me" "$base"`
    fi
else
    #base=`dirname "$me"`
    base=""
    me=`makeAbsolute "$me" "$base"`
fi
# macOS does not like to have // in the middle of the path
me=`echo "$me" | sed -e "s/\/\//\//g"`

export BASEDIR="$(dirname "$me")"

# desktop_icons.tcl { install | uninstall}
"$BASEDIR"/gid -tclsh "$BASEDIR"/scripts/desktop_icons.tcl uninstall

