Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5932545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:50:56+00:00 2026-05-22T14:50:56+00:00

How can I tell what type my shell is? ie, whether it’s traditional sh,

  • 0

How can I tell what type my shell is? ie, whether it’s traditional sh, bash, ksh, csh, zsh etc.

Note that checking $SHELL or $0 won’t work because $SHELL isn’t set by all shells, so if you start in one shell and then start a different one you may still have the old $SHELL.

$0 only tells you where the shell binary is, but doesn’t tell you whether /bin/sh is a real Bourne shell or bash.

I presume that the answer will be “try some features and see what breaks”, so if anyone can point me at a script that does that, that’d be great.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T14:50:57+00:00Added an answer on May 22, 2026 at 2:50 pm

    This is what I use in my .profile:

    # .profile is sourced at login by sh and ksh. The zsh sources .zshrc and
    # bash sources .bashrc. To get the same behaviour from zsh and bash as well
    # I suggest "cd; ln -s .profile .zshrc; ln -s .profile .bashrc".
    # Determine what (Bourne compatible) shell we are running under. Put the result
    # in $PROFILE_SHELL (not $SHELL) so further code can depend on the shell type.
    
    if test -n "$ZSH_VERSION"; then
      PROFILE_SHELL=zsh
    elif test -n "$BASH_VERSION"; then
      PROFILE_SHELL=bash
    elif test -n "$KSH_VERSION"; then
      PROFILE_SHELL=ksh
    elif test -n "$FCEDIT"; then
      PROFILE_SHELL=ksh
    elif test -n "$PS3"; then
      PROFILE_SHELL=unknown
    else
      PROFILE_SHELL=sh
    fi
    

    It does not make fine distinctions between ksh88, ksh95, pdksh or mksh etc., but in more than ten years it has proven to work for me as designed on all the systems I were at home on (BSD, SunOS, Solaris, Linux, Unicos, HP-UX, AIX, IRIX, MicroStation, Cygwin.)

    I don’t see the need to check for csh in .profile, as csh sources other files at startup.
    Any script you write does not need to check for csh vs Bourne-heritage because you explicitly name the interpreter in the shebang line.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way that one can tell if the type that an object
I noticed that the bash shell can suggest command line switches for your command.
Well, I'm completely new to JavaScript. Can you please tell me what type of
can you just tell me for which type of requirement we should choose framework
Can anyone please tell me how to extract this kind of data : [{number:8457215152,type:Cell,state:LA,country:US,tz:CT,zip:70546,msa:0},{number:4363685555,type:Cell,state:LA,country:US,tz:CT,zip:70546,msa:0}]
Can GHC or some lint tool tell me when I've provided a type signature
Is there an easy way by which I can tell which type of Unix
From what I can tell DateTickUnitType is an enumeration that cannot be extended or
How can I tell what type of class is inside a Collection? I need
I was wondering about tools that are built into the bash shell. For example,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.