Slashdot Mirror


A Real Bourne Shell for Linux?

the_code_poet asks: "I'm a lead developer for a software development company, and one of my responsibilities has been writing an installer for our product (of which Linux is one of the platforms). In keeping with UNIX tradition, the installer is written in shell (thats /bin/sh), but as many of you know there is no Bourne shell for Linux - only bash. This has caused inconsistencies (mostly bugs in bash) when writing a generic UNIX sh script that works fine on commerical *NIX's." For a semi-complete list of differences between bash and sh, you will want to check out section C1 of the Bourne Again Shell FAQ. To be honest, I have yet to run into much trouble with a script starting with #!/bin/sh with /bin/bash, and I've been using the latter for years. If any of you have had problems related to this, please tell us what the problem was and how you solved it. Also: would anyone out there be interested in writing a real Bourne Shell for Linux?

"On every distro I've ever seen /bin/sh is just a soft link to /bin/bash. If bash is invoked with sh as its name (argv[0]) then its supposed to act like Bourne - but that just doesnt happen (for example: export FOO=bar is *not* valid Bourne shell syntax, you must say FOO=bar; export FOO)

Do you think that the startup scripts for most distributions would break because, even though they say
#!/bin/sh at the top, they REALLY mean #!/bin/bash?

Given that there is no real Bourne shell for Linux, and that bash has an exhorbitant file size. Quoting bash's man page, here: '...it's too big and too slow' for something that is to be used as the defacto-standard shell for scripting, do you think its a worthy venture to set out to write a small, tight, pure Bourne shell?

*asbestos disclaimer*: This has nothing to with Bash as an interactive user shell and has nothing to do with a holy war over who's favorite shell is better than whomever's."

While doing a small bit of research on this question, I noted there was another Bourn-compatible shell out there called "ash", yet it's billed as doing "some things better and some things worse than bash". Does anyone use it, and find it better than bash for their shell scripting needs?

5 of 388 comments (clear)

  1. Re:How linux is still an inferior desktop OS by HP-UX'er · · Score: 0, Offtopic

    gnome is definitly going on the rise, with more and more *NIX's making it their default GUI in next releases ...

  2. Re:Easy. by istartedi · · Score: 1, Offtopic

    Why has this been marked down to -1?

    Possible explanations:

    1. The moderators are all watching for meteors.
    2. The moderator got hit in the head with a meteor.
    3. The moderators are aliens who just arrived on meteors.
    4. Yo Mama is meteor.

    Take your pick.

    --
    For all intensive purposes, "whom" is no longer a word. That begs the question, "who cares"?
  3. bash SUCKS, csh ROCKS! by rice_burners_suck · · Score: 1, Offtopic

    I personally don't like bash. For one thing, I don't like its syntax. Well, actually, that's pretty much the only thing. I like csh a lot better because it's easier to configure, easier to use, and has a syntax that I like a lot better. (Hey, I figure UNIX is programmed in C; why shouldn't it be used in C as well (or at least in something C-like).) It's too bad csh wasn't the de-facto standard for UNIX systems, instead of sh. OH WELL.

  4. use perl by TheGratefulNet · · Score: 1, Offtopic
    scew bash - use perl.

    for an installer, I'd say it wasn't crazy idea; and for a user's shell, of course it's nuts, but we're talking about an install script.

    you can _always_ count on perl being there (right?). any unix not having at least perl5 is not a unix system, in modern terms.

    personally, I prefer tcsh as my _user_ shell. and its a pretty complete version of the c-shell, but made more livable.

    --

    --
    "It is now safe to switch off your computer."
  5. forget the sh - use ksh by abelikoff · · Score: 0, Offtopic
    Traditional sh is too limited in features, let alone the compatibility problems you've described. Use #!/bin/ksh - it is much more feature rich and free Un*x clones usually have pdksh readily available. You'll be amazed how many things that you did manually in sh are implemented in KSH. KSH is far from perfect but it's probably the most useful one of the entire *sh family (scsh is another story, however).

    We've been using ksh/pdksh very successfully in our projects. As of now, we've got about 200+ ksh scripts and they run perfectly in Linux (Intel and AXP), DG/UX, Solaris, HP/UX and AIX. And no, we haven't hit a single pdksh incompatibility yet.