Saying What You Mean

Mar 21, 2008 / By Sheeri Cabral

Tags: ,

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!)

One Response to “Saying What You Mean”

  • Bill Karwin says:

    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.

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>