
# Minimal shell code

#alias bookmarker_to=cd
# alias not remembered

#BOOKMARKER_TO=x
#export BOOKMARKER_TO
# env vars make it through

# to function not remembered either

#date >> /tmp/bookmarker_to.sh.ran
# proof profile.d script running

# function style "function to() {"
# break login on ubuntu

# function style "function to {"
# not remembered on ubuntu
#     remembered on mageia

# function style "to () {"
# not remembered

function to {
    DEST="/tmp/bookmarker_to.$$"
    mark --to --write-dest "$DEST" "$@"
    RC=$?
    if [ -e "$DEST" ]
    then
        # we need to change directory
        cd "`cat "$DEST"`" >/dev/null 2>&1
        if [ $? != 0 ]
        then
            echo "to: Can not change to directory '`cat "$DEST"`'" >&2
            RC=1
        fi
        rm -f "$DEST"
        # alias adding -i to rm require us to use -f
    fi
    return $RC
    
}

