Saying What You Mean

By Sheeri Cabral March 21st, 2008 at 6:13 am
Posted in SysAdmin
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!)

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Google
  • del.icio.us
  • Facebook
  • bodytext
  • Technorati
  • TwitThis
  • Reddit

One Response to “Saying What You Mean”

  1. 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

Filling out the following captcha not only allows us to cut down on automated blogspam but also helps digitize books. Please feel free to send comments on this approach directly to Paul at vallee@pythian.com.

NOTE: After submitting your comment, verify that it is added to the blog. New comments will be marked as "waiting for moderation" (we only moderate for spam). If the level of spam is as low as we hope, we will bypass this step.