Saying What You Mean

Posted in: Technical Track

Ah, the perils of working in a shared, client environment. One client has us using a login that is not exclusive to us. I prefer using bash; the client is set to use zsh. This is not a problem in and of itself.

However, there is a section in the .profile that is causing me issues:

if [ -f /usr/bin/ksh ]; then
        /usr/bin/ksh -o vi
        exit
fi

So, “If ksh exists, run it with some options to edit history with vi-like commands”. Except what we really want is “If you’re using the ksh as a shell, . . . .”

So I added a modification, and now all is fine.

if [ -f /usr/bin/ksh ]; then
        if [ "$SHELL" = "/usr/bin/ksh" ]; then
                /usr/bin/ksh -o vi
                exit
        fi
fi

(not all my problems are MySQL related!)

Interested in working with Sheeri? Schedule a tech call.

1 Comment. Leave new

Why are you starting another instance of the ksh shell if you know the current process is already a running ksh shell? You can activate the vi behavior of command history editing in the current ksh shell:
$ set -o vi

Also, just because $SHELL is set to a value doesn’t guarantee that it’s accurate. And ksh isn’t always in /usr/bin. It’d be a bit more reliable to test for `basename $0` = ksh.

Reply

Leave a Reply

Your email address will not be published. Required fields are marked *