Results 1 to 5 of 5

Thread: sh vs bash.. what is different?

Hybrid View

  1. #1

    sh vs bash.. what is different?

    Ok so i foolishly made a 6 page script in bash for a system that is running sh (i didnt know this till i tried to run the script). Does anyone know if the syntax for case statements, while loops, or if statements is different in sh than it is in bash? My script sure as blazes is not working right and im having trouble finding any differences in the syntax. It looks like the syntax should be the relatively the same between the two shells (at least the man pages are leading me to that conclusion). Anyone had this problem before? Thanks for any help!

    --Morphman, infinite fountain of questions

  2. #2
    Moderator
    Advisor
    redhead's Avatar
    Join Date
    Jun 2001
    Location
    Copenhagen, Denmark
    Posts
    811

    Re:sh vs bash.. what is different?

    On most systems, theres not that big difference:
    redhead@sindre{51} ~> ll /bin/sh
    lrwxrwxrwx 1 root root 4 nov 8 2001 /bin/sh -> bash*
    redhead@sindre{52} ~>
    But on others, sh is a stripped version of bash, meaning some of the neat functioning features found in bash is missing.
    How ever, the case/while/for statements in the two languages are the same, you still have your
    case x in
    y) something;;
    esac
    for x in y; do
    something
    done
    while (x) do
    something
    end
    if [ x ]; then
    something
    fi
    It could be if you use an unnoted -eq/-ne/-lt (altho these are valid in both)

  3. #3

    Re:sh vs bash.. what is different?

    [quote author=redhead link=board=9;threadid=3715;start=0#37560 date=1023743852]But on others, sh is a stripped version of bash[/quote]

    Actually, sh came first. Bash is an enhanced version of it.

  4. #4

    Re:sh vs bash.. what is different?

    [quote author=Feztaa link=board=9;threadid=3715;start=0#37624 date=1023774218]
    [quote author=redhead link=board=9;threadid=3715;start=0#37560 date=1023743852]But on others, sh is a stripped version of bash[/quote]

    Actually, sh came first. Bash is an enhanced version of it.
    [/quote]

    True, but in todays computer world sh is kind of muddled. You'll find that sometimes sh is a link to bash or ksh93, or even to zsh while other times it is actually some version of sh.

  5. #5

    Re:sh vs bash.. what is different?

    [quote author=Ashcrow link=board=9;threadid=3715;start=0#37630 date=1023776580]True, but in todays computer world sh is kind of muddled.[/quote]

    Yes, sh is just a link to whatever shell they want to use.

    You'll find that sometimes sh is a link to bash or ksh93, or even to zsh while other times it is actually some version of sh.
    When sh is a link to bash, bash runs in sh compatability mode...

Similar Threads

  1. need some bash scripting help
    By mountainman in forum Programming
    Replies: 2
    Last Post: 08-30-2002, 12:44 PM
  2. Bash colo(u)rs
    By airhead in forum Linux - Software, Applications & Programming
    Replies: 2
    Last Post: 06-24-2002, 09:08 PM
  3. Perl to bash
    By Dizzybacon in forum Linux - Software, Applications & Programming
    Replies: 7
    Last Post: 06-22-2002, 07:59 AM
  4. Bash Pet - 2nd part
    By civ1492 in forum Linux - General Topics
    Replies: 2
    Last Post: 06-05-2002, 05:03 PM
  5. Bash PET
    By civ1492 in forum Linux - General Topics
    Replies: 9
    Last Post: 05-14-2002, 12:52 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •