in reply to What shell am I running?

I wonder if someone can come up with a one liner for this.
Yup, a golf challenge.

Replies are listed 'Best First'.
Re: Re: What shell am I running?
by blakem (Monsignor) on Nov 17, 2001 at 06:31 UTC
    It's probably not portable, but this works on linux:
    perl -le 'print$ENV{SHELL}'

    -Blake

      You can shave one char off of that; the -l doesn't do anything. Other then that, I think that's as short as it gets for shells that set ${SHELL} (which is POSIX, I think). (Note that the original isn't portable past whatever Unix they were using; ps's format isn't portable at least to my Linux. For that matter, mine doesn't need the -p parameter.)

      Thanks,
      James Mastros,
      Just Another Perl Scribe

        -l "sets $\ to the current value of $/" (see perlrun)

        In otherwords, it automatically adds a "\n" to all print statements. I like to use it for short one liners, since it helps keep the output separate from my shell prompt.

        Oh, and the options usually aren't counted as keystrokes in one-liner golf. i.e both would score a 16:

        # 1234567890123456 perl -le 'print$ENV{SHELL}'

        -Blake