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?

94 of 388 comments (clear)

  1. Easy. by Flarners · · Score: 5, Informative
    1. Download FreeBSD source.
    2. cd /usr/src/bin/sh; make; make install
    AFAIK the BSD Bourne shell is more or less the same as the real Bourne shell.
    --
    "The problem with the French is that they don't have a word for 'entrepeneur'." -George W. Bush
    1. Re:Easy. by bwulf · · Score: 2, Informative

      4.4BSD-Lite (and derivatives) /bin/sh is Ash.

      Also, recent FreeBSD 4.x releases have replaced 4.4BSD csh with tcsh (original csh being available as a port).

    2. Re:Easy. by prog-guru · · Score: 2, Interesting

      Would this compile? I tried building the FreeBSD telnetd source on other systems when the telnetd exploit came out, and it wouldn't build.

      FreeBSD seems to favor csh anyway, root's shell is csh, they say don't every never change root's shell or your scripts will break (although they are sh scripts), bash is not installed in the base system, the package manager installs it in /usr/local, and bash 1.x isn't statically linked, so you can't use it in single user mode (bash 2.x is).

      I still prefer bash, despite FreeBSD's objections :)

      --

      chris@xanadu:~$ whatis /.
      /.: nothing appropriate.

    3. Re:Easy. by benedict · · Score: 2

      Who says don't change root's shell? Not the FreeBSD Project ... in five years of using FreeBSD, I haven't found a single thing that breaks when root's shell changes.

      --
      Ben "You have your mind on computers, it seems."
    4. Re:Easy. by benedict · · Score: 2

      Who says this? Where? Whoever they are, they've obviously never used single-user mode on FreeBSD.

      When you boot FreeBSD single-user, the last thing it does before giving you a shell prompt is prompt you to tell it what shell to use. If you just press enter, you get /bin/sh.

      --
      Ben "You have your mind on computers, it seems."
  2. /bin/bash by Z4rd0Z · · Score: 3

    Starting your scripts with #!/bin/bash shows that you live in a Linux-centric world. No other OS puts bash under /bin. Since there's normally a link from bash to sh, it really makes sense for compatibility reasons to use #!/bin/sh. Of course, if you use bash-specific features in your scripts, your scripts won't be portable anyway and it doesn't really matter, I suppose.

    --
    You had me at "dicks fuck assholes".
    1. Re:/bin/bash by seebs · · Score: 2

      BSD/OS ships with bash in /bin.

      And yes, I have been burned regularly by scripts which assumed that "sh" would have bash extensions.

      --
      My blog: http://www.seebs.net/log/ --- My iPhone/iPad app: http://www.seebs.net/seebsfrac/
  3. It's a non-issue. by mindstrm · · Score: 5, Interesting

    You are looking for a solution to a problem that does not exist.

    bash is backward compatable to sh. Period.

    Yes, you can do things in bash you can't do in sh, but not vice-versa.

    If you write your scripts for stock Bourne, they will run fine under bash.

    1. Re:It's a non-issue. by Llanfairpwllgwyngyll · · Score: 2, Insightful

      It's not *quite* a non-issue.

      If you want to use sh, start with #!/bin/sh rather than #!/bin/bash - the executable notes which name you invoke it with and adjusts a couple of minor details of behaviour accordingly.

    2. Re:It's a non-issue. by mindstrm · · Score: 2

      yes.. and there are a few other, very minor differences, well documented in the bash documentation, which any devleoper could very easily account for.

    3. Re:It's a non-issue. by pete-classic · · Score: 5, Informative

      What you are saying is valid, but it misses the point.

      Even if every valid bourne script runs perfectly under bash there is still a problem.

      That problem is that an interpreter enforces valid syntax. It would be nice if everyone who wanted to write a portable (read bourne) script spent a month studying and was totally zen-ed out on the subject. But that 'aint the real world.

      I personally could benefit from a real sh on Linux, since it is the only *NIX I have, and I can't test scripts for sh compatibility without it.

      To be more specific, I wrote a bash script that was included in an OSS project. The maintainer wanted me to change the first line from "#!/bin/bash" to "#!/bin/sh" "for compatibility." I told him that I wasn't comfortable with this since the script wasn't tested on sh. He said he tested it and it worked fine. I asked him if he really tested it with sh or with "/bin/sh -> /bin/bash". Turned out it was the latter. Apparently he made the change anyway.

      A while later we got a bug report on the list to the effect "your script is not a valid sh script." Luckily the guy sent a diff, and I tested it with bash. I guess it works with sh now too, but I still don't know for sure.

      See how it isn't a non-issue, at least for me?

      -Peter

    4. Re:It's a non-issue. by seebs · · Score: 5, Insightful

      Embrace and extend. There is no way to write a script in bash and have bash warn you if you're using an extension, so they tend to creep into scripts. Embrace and extend is evil; the compatability mode should be *pure* sh, with no extensions.

      --
      My blog: http://www.seebs.net/log/ --- My iPhone/iPad app: http://www.seebs.net/seebsfrac/
    5. Re:It's a non-issue. by aheitner · · Score: 2

      Just to play devil's advocate here for a minute -- if we're only ever allowed to implement what the standard dictates, how will we ever come up with anything new?

      I mean, sure, you can sit down and write a totally new scripting language.

      And no one will use it.

      All computer systems change evolutionarily. C has evolved within itself quite a bit. C++ is a superset of C, with some caveats. Java is a language whose syntax inherits a lot from the C family, but is quite different.

      Linux is like many other previous Unixes, except ... that it's an evolution, and is different.

      It causes problems. It makes life difficult (everyone who's programmed Unix-like OSs knows that's a pain in the butt).

      But are you seriously going to argue that we should have stuck to the one official narrow definition enshrined by ATT in the early 80s, and that no new implementation should differ in the least?

      ...

      I would argue that "Embrace and extend" refers to, specifically, "Embrace and extend with non-standard, non-free additions that lock customers into our products and only our products, forever".

      Anyone is free to make ksh or ash (or whatever) have a bash bug-compatibility mode to make people's lives easier in porting scripts. Hell, the Linux kernel has bug-compatible syscalls.

      It's a pain. But it's also progress.

    6. Re:It's a non-issue. by psamuels · · Score: 2
      I personally could benefit from a real sh on Linux, since it is the only *NIX I have, and I can't test scripts for sh compatibility without it.

      Next best thing is to test with ash - I do this for exactly the reason you outlined in your post (great post btw). You still won't catch things like using $() instead of ``, of course, but most Unix vendors nowadays seem to have a POSIX /bin/sh anyway. I usually use `` anyway when I want the script to be portable, but $() is so much more readable ... <sigh>

      -another Peter

      --
      "How can you claim that you are anti-crack, while still writing a window manager?" — Metacity README
    7. Re:It's a non-issue. by mangu · · Score: 2

      Extending your point: is there *any* system today that includes sh and only sh as its script interpreter? Is there any compelling reason (other than standards purity) not to just `rm sh; mv bash sh`?

    8. Re:It's a non-issue. by aheitner · · Score: 2

      Yes, actually :-)

      Bash is (arguably) a piece of junk. And it's definitely not intended as a system scripting shell.

      /bin/sh should be ksh or ash.

      zsh is almost definitely a nicer end-user shell (but is, like bash, too bloated for system use).

      ...

      (for the record, I think Solaris comes with "just" a /bin/sh, which is pure Bourne. HP-UX and AIX come with ksh).

    9. Re:It's a non-issue. by psaltes · · Score: 2, Informative

      > What you are saying is valid, but it misses the point.

      Actually, what he says is not even valid. If anyone had bothered to read the link that Cliff helpfully posted, they would see that there are several things bash does not do, and several things that are 'implemented differently'. The following is taken from that page:

      Things sh has that bash does not:
      uses variable SHACCT to do shell accounting
      includes `stop' builtin (bash can use alias stop='kill -s STOP')
      `newgrp' builtin
      turns on job control if called as `jsh'
      $TIMEOUT (like bash $TMOUT)
      `^' is a synonym for `|'
      new SVR4.2 sh builtins: mldmode, priv

      Implementation differences:
      redirection to/from compound commands causes sh to create a subshell
      bash does not allow unbalanced quotes; sh silently inserts them at EOF
      bash does not mess with signal 11
      sh sets (euid, egid) to (uid, gid) if -p not supplied and uid 100
      bash splits only the results of expansions on IFS, using POSIX.2
      field splitting rules; sh splits all words on IFS
      sh does not allow MAILCHECK to be unset (?)
      sh does not allow traps on SIGALRM or SIGCHLD
      bash allows multiple option arguments when invoked (e.g. -x -v);
      sh allows only a single option argument (`sh -x -v' attempts
      to open a file named `-v', and, on SunOS 4.1.4, dumps core.
      On Solaris 2.4 and earlier versions, sh goes into an infinite
      loop.)
      sh exits a script if any builtin fails; bash exits only if one of
      the POSIX.2 `special' builtins fails

    10. Re:It's a non-issue. by seebs · · Score: 2

      Adding features is good, but keep them out of the thing that claims to be the standard version of the language. /bin/sh should be a POSIX shell, period.

      This is why ksh is called "ksh", not "sh".

      --
      My blog: http://www.seebs.net/log/ --- My iPhone/iPad app: http://www.seebs.net/seebsfrac/
    11. Re:It's a non-issue. by Captain+Zion · · Score: 2
      From a diary entry I posted in advogato a few days ago:

      7 Nov 2001 (updated 7 Nov 2001)

      Bash bashing

      Let me state that I have nothing against bash itself. I know it's a very fine, full featured shell with many interesting improvements over other shells. Most, if not all, Linux distributions use it as the system's /bin/sh, which is also fine, but it's the fact that it leaks bash-isms when invoked as sh that is somewhat disturbing. First of all, it allows the creation of a multitude of /bin/sh scripts that are not compatible with the Bourne shell -- replace /bin/sh by ash in your system to see the extension of the damage. Now take your bash-contaminated /bin/sh scripts and try to run them in other, erm, Linux-like systems such as commercial SysV or even BSDs. You can try /bin/ksh, but it won't work in all cases, and you'll be forced to use bash. That's, IMHO, very Microsoftian in nature. It's embrace and extend.

      What I advocate here is that bash scripts must use #!/bin/bash, not #!/bin/sh. Let Bourne shell scripts use #!/bin/sh, Korn shell scripts use #!/bin/ksh, C shell scripts use #!/bin/csh and so on. Let's stick on standards. It just makes sense!

    12. Re:It's a non-issue. by pete-classic · · Score: 2

      Did you even read my post?

      I choose bourne for portability.

      Did you see the part in my post where the guy couldn't use the script because his sh choked on it? Was it not clear to you that his system didn't have bash?

      Now, your post was pretty hard to follow. Maybe you were questioning the fact that I wrote it in bash instead of C?

      If so, since you don't know what my script did, you must be making an argument against the existence (or at least use) of scripting languages?

      If so I would counter that shell scripting is the natural outcome of the *NIX philosophy of small, nimble tools, because shell scripts are the ideal way to "glue" a bunch of these tools together to do novel, powerful things with very little effort.

      I hope you'll clarify.

      -Peter

    13. Re:It's a non-issue. by benedict · · Score: 2

      I had a similar problem. A friend of mine wrote a shell script (#!/bin/sh) for Mac OS X. I brought it over to my NeXT, and it didn't work, because it used zsh constructs that weren't supported in the Bourne shell. It was easy to fix, but it's a good illustration of the type of problem you're talking about.

      --
      Ben "You have your mind on computers, it seems."
    14. Re:It's a non-issue. by benedict · · Score: 2

      YDGI. The point isn't that bash shouldn't implement anything new. The point is that bash should have a mode where all the new stuff is turned off.

      Look at gcc for an example of this. Gcc has extensions, and they are useful and used. No one has a problem with this. But sometimes people want to use gcc to develop truly portable programs. When they do, they use "-ansi -pedantic" (I think; IANAP) to turn off all of the gcc extensions.

      Linux would be a better citizen in the community of unix variants if its Bourne shell implementation offered a similar no-extensions option.

      --
      Ben "You have your mind on computers, it seems."
  4. Re:/bin/bash - It all sounds so brutal by Anonymous Coward · · Score: 3, Funny

    hash bang slash bin slash bash

  5. Slackware uses ash for toolset by dangermouse · · Score: 5, Informative
    Slackware uses ash because (a) it's tiny and (b) it's restrictively Bourne-compatible, which means you won't write some tool that is accidentally dependant on bash.

    Basically, Slackware uses ash for development for the exact reasons you're looking for a Bourne-compatible shell.

    Have fun.

    1. Re:Slackware uses ash for toolset by dangermouse · · Score: 2
      doh. that last post was me, I didn't mean to post anonymously. But no, I actually was referring to the distributions statistics... Red Hat isn't nearly dominant enough to be called a "standard", even if you lump Mandrake in with it (which would not be unreasonable). Debian in particular is giving them a serious run for their money, and that's nice to see. Furthermore, if you take a look at *nix systems in general and not just Linux, the "standardness" of Red Hat dwindles rapidly.

      To address a point (to use the term loosely) someone made earlier: I use Slackware partially for the features some would consider "non-standard". Mostly, those features are what helped me get into Linux in a serious way, and now that I know what I'm doing I'd just adapt if they changed. Tarball-based packaging and BSDish init scripts are really nice, but they don't define Slackware any more than the version of grep or KDE that gets installed does.

      Nobody uses Slackware because it's hip to be different.. we'd all be thrilled if the other major distributions would fall in line. ;)

  6. bash as /bin/sh by zdzichu · · Score: 4, Informative

    "On every distro I've ever seen /bin/sh is just a soft link to /bin/bash."
    You haven't seen Polished Linux Distribution. PLD's /bin/sh is not bash, and all 'bashisms' are removed from distribution's scripts - it's all plain /bin/sh.

    (Plus, PLD is fully IPV6 ready :)

    --
    :wq
    1. Re:bash as /bin/sh by haruharaharu · · Score: 2

      odpierdol siê

      What does that mean anyway? I'm always on the lookout for new ways to be profane.

      --
      Reboot macht Frei.
    2. Re:bash as /bin/sh by Marcus+Brody · · Score: 2

      no no no no no.
      look at their web page.
      from the pictures, it is quite clearly penis linux distribution

  7. Bourne shell or POSIX shell? by psamuels · · Score: 5, Informative
    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?

    Many would. However, note that POSIX requires /bin/sh to be a POSIX shell, whose specs are derived mostly from the Korn Shell - so ksh is a valid POSIX shell, as is Bash, modulo a few features. Plain-vanilla Bourne shell is not.

    AIX has the same dilemma: to be POSIX-compliant they have /bin/sh -> ksh and /bin/bsh is the real Bourne. HP-UX 11 has /bin/sh distinct from ksh, but it too allows things like 'export FOO=BAR'. I don't know if a real Bourne shell exists on HP-UX.

    For a POSIX shell without the bash overhead, use ash, which is distributed with many (most?) Linux distributions. ash is the NetBSD /bin/sh, and at least on Debian the installation gives you the /bin/sh symlink option as well. Let me tell you, ash is much faster than bash in the autoconf-generated-configure "benchmark".

    Since many Debian people use ash for /bin/sh, packages regularly have bugs filed -- and fixed -- vis-a-vis #!/bin/sh vs. #!/bin/bash. I don't know how careful other distros are about this sort of thing. Note that even many Debian scripts would fail if you found a real Bourne shell for /bin/sh rather than a POSIX-compliant shell.

    --
    "How can you claim that you are anti-crack, while still writing a window manager?" — Metacity README
    1. Re:Bourne shell or POSIX shell? by jbgreer · · Score: 2

      Yeah, you're right - /bin/sh should probably refer to ksh. The problem, of course, is that most distros implement ksh using pdksh, which throws some slightly interesting behavior into the mix as well. For instance, even though the UNIX 1 spec says that the last process in the pipe chain can be implemented in sub-shell, practically all implementations do not, except for pdksh.
      I wish distros would pick up the AT&T ksh implementation, since it is actively maintained, standards compliant, and since the source code is available to mere mortals now.

      --
      The Norton Anthology of English Literature, 4th Ed., Vol 2
  8. Did you even read the complaint? by Wakko+Warner · · Score: 4, Interesting

    The guy writes installer scripts for a living. Every other unix has a Bourne shell implementation except Linux, and Linux's /bin/bash has incompatibilities. Telling the guy to fuck off and use something else has got to be the most ignorant thing I've ever heard. I'm sure he can tell his boss the same thing, right? "Fuck this, I'm gonna use ksh so it works on... AIX only!"

    Ask Slashdot becomes less helpful by the nanosecond.

    - A.P.

    --
    "Remember when the U.S. had a drug problem, and then we declared a War On Drugs, and now you can't buy drugs anymore?"
    1. Re:Did you even read the complaint? by aheitner · · Score: 4, Insightful

      Yes. I did.

      And it was nonsensical.

      If he's going to complain about bash being not exactly POSIX, he's got to show an example of an incompatibility (as a decent sometime bash and ksh hacker, I can't think of one -- and I can think of one subtlety that ksh and zsh do differently than POSIX: word splitting).

      Ok. "export FOO=bar" doesn't work on a strictly-POSIX shell. But why is it bad for that to work in bash (and ksh and zsh)? How does that hurt you?

      Instead, why doesn't the article's poster come up with an example of a valid POSIX statement that breaks in bash -- that way he actually has a complaint: he did something POSIX (i.e., the standard), and bash did the wrong thing. As it stands, he's just griping.

      I mean, I agree with him -- bash is bloated and not a good choice for scripting. But that just means that scripts should be written in a shell optimized for scripting -- ksh. Or at least a minimalist straightforward POSIX shell (ash).

      But if a system wants to provide just one POSIX shell (to save space, or whatever), and if bash is going to be used by 95% of users anyhow (so is likely to be loaded anyhow), making the one POSIX shell available on the system be bash isn't a bad call. Now that doesn't excuse scripts using non-POSIX features under the name of /bin/sh. But I'd hazard to guess that 99% of the time those scripts are distro-specific in many other ways, so it doesn't really matter.

      I still have yet to see how (from anything but an efficiency perspective), this guy is finding that bash somehow makes his life harder.

      (side-point: it is annoying that you can't solve the efficiency problem by relinking /bin/sh to ksh or ash, since all the system scripts will do slightly-non-POSIX things and therefore should be specifying /bin/bash).

      ...

      I apologize for my confrontational tone. It really irks me when people propose writing things without bothering to check if the work has been done for them. I mean, come on, guys, it's Free Software. Avoiding duplication is the name of the game.

    2. Re:Did you even read the complaint? by larien · · Score: 2
      ksh is available on stock IRIX, AIX, Solaris and HP-UX. Even linux/FreeBSD can now have it for free after some fairly recent license loosening.

      On the other hand, bash is standard on linux, FreeBSD and Solaris 8 (maybe even AIX 5L? haven't seen that yet). Hrm, let me see which is more widespread? :)

      Personally I prefer zsh for interactive stuff and it's as good as bash/ksh for most scripting stuff. I say most, because otherwise someone will come back with some whiz-bang feature of bash/ksh to prove a point. Most of my scripting works fine in sh; that's the stock sh that comes with most versions of Unix, but then I don't do very much fancy stuff.

    3. Re:Did you even read the complaint? by cartman · · Score: 2

      How did your comment get moderated up to a 4? Did you even read the comment to which you're responding? He did not tell the original poster to "fuck off," as you say. He mentioned an additional shell that is bourne-compatible and COMES WITH LINUX, thereby answering the original concern. Your mindless flame was the only comment with terminology like "fuck off."

    4. Re:Did you even read the complaint? by duffbeer703 · · Score: 2

      The issue here is portability.

      His point is that if Linux had a real Bourne Shell, he's wouldn't have to give two shits about what distro/version/patchlevel was installed as it related to his install scripts.

      On Solaris, AIX, SunOS, DECos, HPUX, etc., you get the real /bin/sh. sh has been the same for years and is absolutley reliable.

      Will bash work 95% of the time? Yes. But bash is still a work in progress, and more bugs will likely be found in the future. sh is sh and isn't being actively "enhanced" anymore.

      --
      Conformity is the jailer of freedom and enemy of growth. -JFK
    5. Re:Did you even read the complaint? by psamuels · · Score: 2, Insightful
      His point is that if Linux had a real Bourne Shell, he's wouldn't have to give two shits about what distro/version/patchlevel was installed as it related to his install scripts.

      In that case, the question should have been more like "(a) why didn't someone open-source the real Bourne shell many years ago so we could have had a mature implementation of /bin/sh, or (b) why didn't Red Hat license the real Bourne shell, or (c) why did Chet not squash all the bash bugs by the time he released 1.14, so when Red Hat went to use it with RH Linux 6.1 they would have a solid sh implementation?"

      The answers are easy enough: (a) the owner of the Bourne shell didn't release it as open source for ... well, whatever reason, it's not important. The important thing is, they didn't, so what are you gonna do about it? Answer: write a new implementation. And that's what Chet and co. did for the GNU project with bash, only it was started many many years after the original sh, so until a few years ago it still had weird bugs in it. The answer to (b) is that Red Hat chose to use only open-source software for ... again, the reasons are not important here.

      As for (c), whose fault is it that a buggy bash was shipped with Red Hat Linux 6.1? Dunno - I think bash 2.0 was out and in active use by the time it shipped, but I'm not sure. And I'm not sure ash wasn't just as bad, at the time, so you can't blame Red Hat for that either.

      In summary, he (and you) are griping about what someone released a couple years ago and they (and you) are still forced to support. Nothing much can be done about it now - it's a solved problem, bash 2.x has been out for quite awhile, but you can't really make people upgrade to it. (Same goes for alternative shells like ash - they're available and they work fine, but you can't make people install them either.)

      --
      "How can you claim that you are anti-crack, while still writing a window manager?" — Metacity README
    6. Re:Did you even read the complaint? by duffbeer703 · · Score: 2

      Bash is not an open-source implementation of sh. As other posters have mentioned in detail, bash vs. sh behavior can vary, since most all implementations of sh have bugs which have become defacto 'features' that bash 'fixes'.

      In addition, as other posters have mentioned in detail, bash introduces new shell features which tend to slip into scripts and break those scripts when they are run on commercial Unix sh implementations.

      My only gripe is that /bin/sh in Linux isn't /bin/sh -- it is bash. It's one more thing that makes incorporating Linux into a commercial Unix enviroment a royal pain in the ass.

      --
      Conformity is the jailer of freedom and enemy of growth. -JFK
  9. Ash by runswithd6s · · Score: 3, Interesting

    Ever try ash? Here's a size comparison just to intrigue you a bit.

    (82780) /bin/ash*
    (407356) /bin/bash*
    --
    assert(expired(knowledge)); /* core dump */
  10. Re:Not "sh" for Linux... by dangermouse · · Score: 2
    There are a lot of Bourne-compatible shells that aren't bash-compatible. So sometimes it makes sense to develop for Bourne, if you have to do shell scripting.

    On the other hand, sometimes you just don't care, and you can make full use of bash or ksh or whatever.

  11. As to distro startup scripts... by Anomie-ous+Cow-ard · · Score: 3, Informative
    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?

    I couldn't say for other distros, but Debian policy says that /bin/sh can be any POSIX-compatible shell, with the one extension that 'echo -n' must not generate a newline. If any script uses /bin/sh assuming bash features, it's considered a serious-level bug.

    --

    --
    perl -e'$_=shift;die eval' '"$^X $0\047\$_=shift;die eval\047 \047$_\047"' at -e line 1.

  12. Re:2nd hit on Google by pete-classic · · Score: 2

    How is that helpful? It suggests "download[ing] the real thing and use[ing] that" with no link or even indication of where to get the real thing.

    I was excited when I saw this story, and again when I saw your post, because I had the same question in the past and was never able to find a satisfactory answer.

    Still haven't.

    -Peter

  13. Re:Try this out! by anothy · · Score: 2, Insightful

    problems here:
    first, what's the first script to be written in, that it'll run on any unix? i guess this is easier than the general case, but still not an issue to ignore.
    also, this more than duplicates the work of writing and maintaining these scripts. you've got the install scripts twice, plus the selector script.

    --

    i speak for myself and those who like what i say.
  14. ash (for debian, at least) doesn't work by mikeage · · Score: 2

    I don't know the exact reason why... I barely know anything about shell scripting... but some shells that say /bin/sh will only work on my system if they use bash. Ash fails due to some difference in how it handles parentheses or file names or something... hopefully someone who knows shell scripting can elaborate ;)

    --
    -- Is "Sig" copyrighted by www.sig.com?
  15. not quite right by Cylix · · Score: 2

    "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)" Not quite right. the syntax export VAR=VALUE is a shorthand method. It is still perfectly alright to VAR=VALUE and then export VAR. I've not run into a comptability problem running scripts under bash, but that does not mean they exist. You can of course recompile bash to function differently ie, for statements can act more like C for statements then their bash versions. Still, tinkering with your shell nulls all warranties, in a sense anyway. Bash has a huge install base and is most likely the shell you will find on most linux systems. If you are really interested in supporting it, you will most likely have to code around its problems. ie, doing a revision check and using X function instead of Y.

    --
    "You should always go to other people's funerals; otherwise, they won't come to yours." -- Yogi Berra
  16. And which "real Bourne shell" would that be? by mj6798 · · Score: 4, Insightful
    There have been lots of different versions of the "real Bourne shell" over the years. From a practical point of view, you should have no problem writing scripts that run in bash and in whatever shell you consider "real". Stick to the POSIX specs where possible.

    However, why are you writing "installer scripts" anyway? If you want to deliver on Linux, please use the Linux packaging system. If you deliver on Solaris, please use the Solaris packaging system. Etc.

    1. Re:And which "real Bourne shell" would that be? by swillden · · Score: 2

      If you want to deliver on Linux, please use the Linux packaging system.

      What is the Linux packaging system?

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    2. Re:And which "real Bourne shell" would that be? by psamuels · · Score: 2, Interesting
      However, why are you writing "installer scripts" anyway? If you want to deliver on Linux, please use the Linux packaging system. If you deliver on Solaris, please use the Solaris packaging system. Etc.

      The Linux packaging system? There are several, at least three of which (rpm, deb, tgz) are in common use.

      It's a valid question, but there are a lot of packaging systems out there - the ones for AIX, HP-UX and IRIX don't resemble each other in the least. Besides, while I don't mind installing packages on AIX or IRIX, the HP-UX 'depot' format and supporting tools are so clumsy that I'd rather run a vendor install script, and worry about uninstalling "manually", any day of the week. (In practice, vendors like Dassault, PTC and MSC never use the native install format - they always supply a script. And that script always seems to assume POSIX shell features. It is also always poorly-written, but that's a different rant.)

      --
      "How can you claim that you are anti-crack, while still writing a window manager?" — Metacity README
    3. Re:And which "real Bourne shell" would that be? by talonyx · · Score: 2

      The Linux Packaging System?

      Sorry, but do you mean deb files, or rpm's, or perhaps a gzipped tarball with a makefile inside?

      When there's no real set standard, it's fine to write an install script. Plenty of programs do it.

    4. Re:And which "real Bourne shell" would that be? by mj6798 · · Score: 2

      The one for the distribution you are targetting. If you target multiple distributions, use the native packaging system on each.

    5. Re:And which "real Bourne shell" would that be? by printman · · Score: 2
      Well, under Linux anyways there are at least 3 packagers that are used for Linux distributions.

      In any case, programs like my EPM (see http://www.easysw.com/epm/ for more info) are designed to create installation scripts, or RPM packages, etc. Definitely worth a look if you want to ship binaries for multiple platforms or even just multiple Linux distributions...

      --
      I print, therefore I am.
  17. Re:Debian uses ash. by PigleT · · Score: 2

    Last I checked, it wasn't just the size, at all, but the whole POSIX-compliance/bourne-compat thing, anyway.

    Besides, given my experiences with "bourne" on AIX/Slowlaris/HP/whatever, I'd be quite happy for the whole concept to die a horrible death, standardise on simple bash and have done.

    --
    ~Tim
    --
    .|` Clouds cross the black moonlight,
    Rushing on down to the circle of the turn
  18. Which direction are you worried about? by MarkusQ · · Score: 5, Interesting
    I think that there is some confusion here. The_code_poet clearly asked about compatibility going from sh to bash (i.e., he wants to write standard sh scripts and have them work on linux, and therefore bash). But the incompatibilities everyone is discussing (e.g. initialized export syntax) are all going the other way; things that you can write under bash that won't work under sh. So what?

    The things that matter are first, the things sh has that bash does not (from the FAQ):

    * uses variable SHACCT to do shell accounting
    * includes `stop' builtin (bash can use alias stop='kill -s STOP')
    * `newgrp' builtin
    * turns on job control if called as `jsh'
    * $TIMEOUT (like bash $TMOUT)
    * `^' is a synonym for `|' * new SVR4.2 sh builtins: mldmode, priv

    ...and the implementation differences:

    * redirection to/from compound commands causes sh to create a subshell
    * bash does not allow unbalanced quotes; sh silently inserts them at EOF
    * bash does not mess with signal 11
    * sh sets (euid, egid) to (uid, gid) if -p not supplied and uid < 100
    * bash splits only the results of expansions on IFS, using POSIX.2 field splitting rules; sh splits all words on IFS
    * sh does not allow MAILCHECK to be unset (?)
    * sh does not allow traps on SIGALRM or SIGCHLD
    * bash allows multiple option arguments when invoked (e.g. -x -v); sh allows only a single option argument (`sh -x -v' attempts to open a file named `-v', and, on SunOS 4.1.4, dumps core. On Solaris 2.4 and earlier versions, sh goes into an infinite loop.)
    * sh exits a script if any builtin fails; bash exits only if one of the POSIX.2 `special' builtins fails

    None of these seem to me to be show-stoppers if you are writing the script from scratch (or even porting a reasonably written one)--I mean really, are you counting on it to dump core if you use multiple option arguments? Is there some reason you can't ballane your quotes? So my question to the_code_poet is, what exactly are you trying to do in sh that won't work in bash?

    --MarkusQ

    1. Re:Which direction are you worried about? by MarkusQ · · Score: 2
      Moderators, you might want to mark down messages like the parent that miss the point entirely.

      Now back to the point, which is discussing how we can write scripts to be run on environments with bourne shell only when we're developing on linux, which doesn't have a fully compatible bourne shell.

      I beg to differ. Before you recommend that someone be modded down, you might want to actually read the article. If you do so, it's clear that the_code_poet isn't developing on linux; he/she is wanting to run scripts developed under sh/*NX under bash/linux. Thus my point.

      -- MarkusQ

  19. Question exchange? (OT) by vrt3 · · Score: 2
    When was the last time you used question exchange? (I presume you mean http://www.questionexchange.com?). I'm asking you since I got an email from them back in July, stating that QuestionExchange was closing down (no doubt as a result of certain events at VA Linux).

    I even submitted a story about it, but it was rejected:

    • 2001-07-30 19:57:03 QuestionExchange Closed Down (articles,news) (rejected)
    --
    This sig under construction. Please check back later.
  20. Re:2nd hit on Google by Vanbo · · Score: 2, Informative

    Ok guess its never going to get modded up because it has FreeBSD in it...

    Here is the source to what is very close to "the real thing"

    ftp://ftp.freebsd.org/pub/FreeBSD/branches/4.0-s ta ble/src/bin/sh/

    So the answer is still, "Use the real bourne sh" and here is how you do it. Download, compile (on linux) and install to some place that won't effect linux. Have your install script call the newly made "real" shell.

    Wasn't hard eh?

    --
    VANBO
  21. (Sorry, a little clarification) by aheitner · · Score: 3, Insightful

    I apologize if my tone comes off confrontatively :-).

    I'm reacting negatively to the idiotic suggestion that people need to waste time "writing a real Bourne shell for Linux".

    If you don't like bash, there are several other shells which attempt to be POSIX. Some of them are quite strict (ash). Some are optimized for scripting (ksh).

    If you want to argue that bash sucks and should be replaced as the default system scripting shell, I totally agree. If you want to say that it sucks when scripts request /bin/sh but use bash-specific features, I agree.

    But for goodness sake, give some respect to the work that's been done.

    ...

    I did see one good post noting the bash specifics that are missing, as a POSIX shell. They really are quite minor...

    1. Re: (Sorry, a little clarification) by psamuels · · Score: 4, Insightful
      In bash you cannot do this:
      test -d "$dir" || ( echo "$dir doesn't exists"; exit 1)

      That's buggy, isn't it? The () force the 'exit 1' to occur in a subshell, so the main script doesn't exit anyway. Use {...;} instead of (...) for what you want.

      Thus, autoconf creates this kind of exit:

      What you are seeing in autoconf macros is an attempt to support every single Unix vendor shell ever released, including old versions of bash that had weird bugs since bash had not yet matured ... but also weird bugs in old versions of other shells. Are you sure the above workaround is for bash, specifically?

      [As an aside, note that the autoconf macro also directs output to two separate files, adding to its complexity. Apples to apples, etc.]

      If you are trying to do that, certainly you will have to jump through hoops.

      If you can assume bash 2.0 or above, you shouldn't really need any bash workarounds.

      Depends on what your requirements are, I guess.

      --
      "How can you claim that you are anti-crack, while still writing a window manager?" — Metacity README
  22. That's like Jumbo Shrimp by john@iastate.edu · · Score: 2
    ... standardise on simple bash ...

    Simple bash -- A phrase I'd never expect to hear!
    On my system:
    131072 sh
    688128 bash

    --
    Shut up, be happy. The conveniences you demanded are now mandatory. -- Jello Biafra
  23. What the author really wants is a POSIX-only Shell by fwc · · Score: 2
    Obviously what the author wants is a shell which implements just the POSIX standard and nothing else. Or maybe expanding just a little bit, wants a shell which JUST implements the Bourne syntax which is available in all Bourne-compatible shells.

    I can understand the reason for this when writing an install script - specifically it is desirable to write to the lowest common denominator and thus make it compatible with everything.

    However, I can't think of a single shell which actually implements just POSIX, or Bourne syntax for that matter. There are dozens of shells out there which all will chew on a real POSIX or Bourne script and spit out something which is pretty close to what the script author intended. However it seems that all of the shell authors have done stuff a little differently than each other so if you've only written and tested on one shell, you might have problems running on any one (or all) of the other shell(s).

    The best thing to do is to pick something small which is as close to just POSIX implementation as you can get (ash perhaps?) and write/develop in that shell and then thouroughly test it on things like bash, ksh and other POSIX shells.

    I always like to through out the fact that most systems now have perl available on them and in some cases it is probably just as appropriate if not more so to script install stuff in perl.

  24. Re:No other OS? by green+pizza · · Score: 3, Interesting

    1. There is no such thing as Solaris 2.8, and 2.7 only exists in some places. I assume you meant 7 and 8.

    Bah, "Solaris" is the marketing name. It's SunOS 5.8. Do a 'uname -a' if you don't belive me. Besides, it fits perfectly with SunOS history... versions prior to 5.0 were BSD based, version 5.0 and newer are heavily SysV based. The whole "Solaris" name just confused everyone.

  25. Re:No other OS? by Doktor+Memory · · Score: 3, Funny

    There is no such thing as Solaris 2.8, and 2.7 only exists in some places. I assume you meant 7 and 8

    You're just going to have to imagine me dressed up as Moon Unit Zappa circa 1985 as I intone from on high here:

    Whatever.

    Sun's breaking of a perfectly functional numbering convention for the sake of their marketeers is, well, their own lookout. Every other reader knew exactly what I was talking about, and only you were dumb and/or desperate enough to think that you could score some sort of lame debating point by pointing it out.

    bash was only introduce into Solaris as of Solaris 8

    Hm, I'm pretty sure I recall it showing up in one of the MU packs for 7, but I could be wrong on that count -- I was mercifully spared the experience of 7 for the most part.

    /bin is actually a symlink to /usr/bin, so technically it doesn't put it under /bin

    From Moon Zappa straight to William Shatner: GET. A. LIFE.

    --

    News for Nerds. Stuff that Matters? Like hell.

  26. Portable Shell Programming by cvanaver · · Score: 2, Informative

    I've run into this problem in the past as well. My solution was to abandon Bourne shell as a scripting shell and use ksh instead. To be 100% portable, you should use Bourne, but most of your major *NIXes have support for ksh (including linux, Solaris and AIX..not sure about HP-UX) and it has a lot of nice scripting gizmos like associative arrays, printf command, co-processes, pattern matching, etc. Of course, maybe you don't need all of that stuff.

    As an aside, there has been a lot of extensive research on making portable shell scripts. Bruce Blinn's book Portable Shell Programming: An Extensive Collection of Bourne Shell Examples is a good resource that might help as well as GNU Autotools documentation, which is the definitive guide on this sort of thing. Another useful jumping off point that has some good materials and a lot of useful links is Shell Script Porting Guidelines

  27. Which Linux packaging system? Obviously... by mj6798 · · Score: 2

    The Linux packaging system for each of the distribution(s) you are targetting. That means packaging each for Debian, RedHat, and possibly others.

  28. ash beats bash by something like 10% by mangu · · Score: 2

    Wow, do you mean with ash I could use a Pentium III 780 instead of 866? Let's face it, given Moore's law, any speed improvement less than n vs. n^2 is more or less irrelevant.

    As for memory usage, bash is about 0.5 megabytes, any memory chip that small is obsolete, and very expensive. Better get 64 megs or more, compared to which both sh and bash are about zero size.

    In the dependencies issue, I admit you are right. But so many other packages need those same libraries that it's very likely you'll need them anyhow.

    All in all, I think this "sh or bash" thing will be an issue only in a very few restricted cases, mostly embedded systems.

    1. Re:ash beats bash by something like 10% by dorzak · · Score: 2

      On one server I regularly do development on, it is a Duron 800, but a quick and dirty of the following turnd up 10 instances of bash running. Either in scripts that are running in the background, or active users. Each one taking up some space in RAM. 4 of them are runninng scripts that are there to restart muds if they crash, and they will stay resident until the mud is shutdown. This is just one relatively small server with a few muds hosted on it. If ash or a true bourne shell would do a better job in less, you know what I say we need it.

      I do not own the server, but I pay to host a MUD off of it.

      However, before you go saying to use tcsh, or csh, they seem to use more memory than bash.

      Also the size of the binary does not always equal the size of the memory it takes up. The executable for the mud is 2.1 megs, but when it loads all of the related files takes up about 12 megs of RAM.

    2. Re:ash beats bash by something like 10% by Dwonis · · Score: 2
      Wow, do you mean with ash I could use a Pentium III 780 instead of 866? Let's face it, given Moore's law, any speed improvement less than n vs. n^2 is more or less irrelevant.

      Maybe, but did you really want the $50 you spent for the 866 to be used in a fat command shell? Most people don't. The other problem is that lately, every developer seems to be saying this, and it's really starting to add up.

    3. Re:ash beats bash by something like 10% by Dwonis · · Score: 2

      Well no, but you have to make it look new so you can get people enthusiastic about it. :-/

  29. Re:bash SUCKS, csh ROCKS! by psamuels · · Score: 2, Informative
    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.

    This reads like a troll, but it could be sincere, so I'll treat it seriously. How do you open more than two output file or more than one input file concurrently? csh has no primitives for opening and closing files beyond redirecting a single command or pipeline. Even for something as simple as redirecting stdout to one file and stderr to another, you have to jump through hoops.

    I won't read back to you the famous Considered Harmful file, but the above point is probably the main reason I would never program with csh scripts. Sure, csh has some programming features Bourne shell lacks, but ksh/bash/POSIX have those same features. Opening and closing arbitrary files is something I do in my scripts all the time.

    --
    "How can you claim that you are anti-crack, while still writing a window manager?" — Metacity README
  30. Comment removed by account_deleted · · Score: 2, Interesting

    Comment removed based on user account deletion

  31. Linux Standard Base by kingdon · · Score: 5, Informative

    Others have addressed the various issues about what is a "real" Bourne shell and bash extensions and all that. Anyway, the Linux Standard Base has a section on shells. In a nutshell, bash 2.x was the most POSIX-compliant of the shells that the LSB tested (and no, I don't know exactly what versions or which shells or the like), with pdksh getting an honorable mention. And there were two ways in which bash was not POSIX-compliant and concerning which the LSB therefore diverges from POSIX (whether $0 is the full pathname or just the basename, and what happens if you try to use "." to run a script without the read bit set). I don't know whether a future version of POSIX is planning to change the specification, or whether this is likely to remain a divergence for the foreseeable future or what. In any event, these two issues shouldn't be hard to deal with in writing scripts.

  32. Example bash bug by kevinank · · Score: 3, Interesting
    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.

    The following works in UNIX sh, but not in bash:

    /sbin/ls -l | while read bits links user group size junk ; do
    echo $user $group
    done

    To work around the bug you can either put the output of ls into a file and redirect input to read from the file, or you can use an immediate mode file (EOF) in the script, but pipes are broken with respect to read.

    --
    LibBT: BitTorrent for C - small - fast - clean (Now Versio
    1. Re:Example bash bug by wayne · · Score: 2, Interesting

      You don't say what the results from using bash are, but your code worked just as I would expect on my Debian system using bash. That is, it prints out the user and group of each file in the current directory. Well, I had to change /sbin/ls to ls (or /bin/ls), but that doesn't seem to be a problem with bash...

      --
      SPF support for most open source mail servers can be found at libspf2.
    2. Re:Example bash bug by scrytch · · Score: 2

      Works just dandy with bash on my box. Cygwin bash at that.

      --
      I've finally had it: until slashdot gets article moderation, I am not coming back.
    3. Re:Example bash bug by kevinank · · Score: 2
      Actually I was probably trying to set a variable within the loop and inspecting it after the loop completed. But you made a good call; I generalized the case that I knew didn't work incorrectly; so thanks for the correction.

      That has really been annoying me for a couple of years now, just not enough to really figure out why the hell it was broken.

      ...runs the last expression in a pipe chain in a subshell. Bizarre.

      --
      LibBT: BitTorrent for C - small - fast - clean (Now Versio
  33. Re:bash SUCKS, csh ROCKS! by tbuskey · · Score: 2, Informative

    csh isn't portable

    I had to port a 1500 line csh script from Ultrix to SunOS, Solaris, Dec OSF, HP-UX, and SGI Irix.

    After getting it to work on Ultrix and SunOS, I tried to get it going on Solaris. csh wasn't even portable from SunOS to Solaris!

    The solution was to use /bin/sh. It is portable. I bet that code would work on bash too.

  34. Too much history by Bruce+Perens · · Score: 2
    The Bourne shell is written to interpret an Algol-like language. Think about that. The original source code had very ugly preprocessor tricks to make C look like Algol. Steve Bourne had Algol on the brain, it was really ugly.

    Who uses Algol today? We now have much more elegant shells like "rc", either the "rc" clone that is shipped with most Linux systems, or maybe even the original Plan 9 "rc" designed and written by Tom Duff.

    There is some room for improvement in the art here. It bothers me that the first goal is to be compatible with something that ran in 1971.

    Thanks

    Bruce

    1. Re:Too much history by Evangelion · · Score: 2, Interesting


      There is some room for improvement in the art here. It bothers me that the first goal is to be compatible with something that ran in 1971.


      That "goal" is to provide people on Linux with a shell with which they can develop portable sh scripts. One that, by being written to, allow you to write scripts that will run on all the other POSIXish sh's out there on other Unicies. Because, well, those things are nessecary in the real world.

      Why does giving system administrators and developers what they need to make thier lives easier bother you?

    2. Re:Too much history by dangermouse · · Score: 2
      Well, the reality at the moment is that most people and systems use a Bourne-compatible shell, and /bin/sh is almost universally a Bourne-compatible shell.

      So it makes sense to develop startup scripts and basic tools for Bourne. From there, it's a small step to "it makes sense to develop under Bourne", which is the point I was addressing in my original response.

      Very few people use a strict Bourne shell on a regular basis. It's just the lowest [most-]common denominator. If something more featureful and less weird were to take its place, I'd be down with that.

      (BTW, I obviously don't speak for Slackware. It'd be really nice if Slash would stop displaying that email address. I asked it to do so, even gave it a new one to display instead...)

    3. Re:Too much history by taniwha · · Score: 2, Informative
      ok - as a one-time algol programmer, and user of Unix V6 (god I'm dating myself :-) - I think Steve had Algol68, not Algol itself on the brain.



      Circa 1971 Algol68 was a 'state of the art launguage', mind you it was one that proved to be a bit too hard to implement well. Most of the easy stuff ended up in Pascal (and some in pascal).



      C's 'struct' and 'union' keywords for example almost surely came from (or via) algol68

    4. Re:Too much history by Bruce+Perens · · Score: 2
      I'd accept "Algol68". I came on the Unix scene in 1981, but we still had V6 systems, and a commercial application (the Images paint system from NYIT Computer Graphics Lab "CGL Inc.") that lived on V6 until 1988 or so. I actually ported the 2.8BSD segmentation overlay loader back to V6, along with fsck, etc.

      Bruce

  35. Re:bash SUCKS, csh ROCKS! by Ded+Bob · · Score: 2

    FWIW, I'm currently a tcsh user, although I have been looking very hard at zsh the past week or so and will probably switch very soon now. zsh solves a lot of the problems I've been having with tcsh...

    I was a tcsh user until a few weeks ago. I switched over to zsh. It takes a bit of getting used to it, but it is very nice. If tcsh had functions and stdout and stderr separation (redirecting stdout to one file and stderr to another), I probably would have continued to use it.

  36. Re:bash SUCKS, csh ROCKS! by Mike+Hicks · · Score: 2

    csh (and tcsh) do not use a C-like syntax. I'm not sure what you call it, but it sure isn't C.

  37. Re:Not "sh" for Linux... by Zo0ok · · Score: 2
    Asking [the vendors] to include bash and install it as /usr/bin/bash however, is quite reasonable.

    AFAIK bash is GNU so vendors may have license problems including it. I think this is why Apple is not including bash in Mac OS X.

  38. Re:Not "sh" for Linux... by AndyElf · · Score: 2, Informative
    To quote from FreeBSD Handbook:

    6.12. Why is /bin/sh so minimal? Why doesn't FreeBSD use bash or another shell?

    Because POSIX says that there shall be such a shell.

    The more complicated answer: many people need to write shell scripts which will be portable across many systems. That is why POSIX specifies the shell and utility commands in great detail. Most scripts are written in Bourne shell, and because several important programming interfaces ( make(1), system(3), popen(3), and analogues in higher-level scripting languages like Perl and Tcl) are specified to use the Bourne shell to interpret commands. Because the Bourne shell is so often and widely used, it is important for it to be quick to start, be deterministic in its behavior, and have a small memory footprint.

    Granted, not really Linux-related answer, however it does answer the question. Also, note last para of the question -- this is not about interactivityportability.

    --

    --AP
  39. Why stay in the past? by chrysalis · · Score: 2

    Actually, is writing korn or bourne shells the way to go?
    We're year 2001. ZSH, Bash and Tcsh are there for years, and they work on all platforms out there, including Windows. They provide a lot of enhancements over Ksh and sh (kick-ass completion, readline, floating point arithmetic, a lot of handy shortcuts and builtins, etc) .
    So, the way to go is probably to use nowaday's tools, not 20-years old ones.

    --
    {{.sig}}
    1. Re:Why stay in the past? by Watts+Martin · · Score: 2
      "They provide a lot of enhancements over ksh and sh (kick-ass completion,"

      So does ksh.

      "readline,"

      If you mean inline editing, more generally, so does ksh, using both Emacs and vi keybindings if you wish.

      "floating point arithmetic,"

      Yep, so does ksh.

      "a lot of handy shortcuts and builtins, etc)."

      Well, you know what this line would be, right?

      A lot of Linux distributions are using "pdksh," which is based on an earlier standard. Ksh is actually a pretty advanced scripting language (with indexed and associative arrays, compound variables, 'printf' formatting and an execution-tracing debugger), and theoretically it's 100% backward-compatible with sh.

      Personally I've taken to zsh myself, but don't 'dis' ksh. :) It's pretty sophisticated. It's unfortunate that 'ksh93' hasn't made its way into wide use, or at least wide inclusion in distributions, yet; linking '/bin/sh' to the 1993 ksh release might be a little more 'true sh compatible' than bash, which is really what this topic was about.

  40. Re:a real bourne shell by mangu · · Score: 2

    Perhaps, if you use apt and only apt, then it will work. In my case, I have tried "upgrading" a system where some of the packages where more up-to-date than the apt package in the FTP server (I had already compiled newer versions from source). Disaster.

  41. Check for bash during configure by Charlotte · · Score: 2, Interesting

    The problem is that Linux programmers don't stop to think about whether the shell they use e.g. during installation or with wrappers, is actually present on the system.

    Being a solaris admin I regularly have to edit shell scripts to put the right path for bash in (/opt/local/bin/bash).

    Software programmers should make their code more portable. In other words, fix configure to look for bash in the path and use that at the top of installation/wrapper scripts. In normal circumstances making the fixes isn't that much work, but you can see that it becomes much more of a problem when compiling something as humungous as Gnome because you can't automate the compiles/installs.

  42. Re:No other OS? by Doktor+Memory · · Score: 2

    I have done 20 or so solaris installs, and I can tell you my least favorite part is bootstraping the machine to the point that my config scripts can take over...

    Er, not heard of Jumpstart, have you?

    --

    News for Nerds. Stuff that Matters? Like hell.

  43. Shared-copy-on-write is PATENTED by yerricde · · Score: 2

    Have you ever heard of shared-copy-on-write executables?

    Have you heard of U.S. Patent 4,742,450 on the shared-copy-on-write memory segments that loading such executables requires?

    --
    Will I retire or break 10K?
  44. Embedded systems more important than you think by yerricde · · Score: 2

    All in all, I think this "sh or bash" thing will be an issue only in a very few restricted cases, mostly embedded systems.

    By dismissing embedded systems as a "few restricted cases," you misunderestimate their ubiquity and importance. Go to Worst Buy or Shircuit Shitty and look at the PC section vs. the sections that have TiVo, WebTV, GameCube, etc. Do you see more PCs on the shelf, or more embedded devices on the shelf? For instance, TiVo runs a Linux kernel, and Dreamcast and PS2 also have Linux available. (Sony will soon bring PS2 Linux Kit to the U.S.) Now would you rather run bash (Bloated A$$ SHell), or would you rather run something smaller and be able to add more features on a given set of fixed hardware such as a game console or a poor student's PC?

    --
    Will I retire or break 10K?
  45. Solution for Debian users by Dwonis · · Score: 2
    apt-get -y install ash ; ln -sf ash /bin/sh

    This actually works pretty well, and it's great for finding broken sh scripts.

  46. You are clueless, there is a POSIX standard! by Kaz+Kylheku · · Score: 2
    The term ``Bourne Shell'' is historic; it refers to the original program written by Stephen Bourne and some more or less direct derivatives.

    The modern thing is simply the POSIX shell command language; If you write in the POSIX language, avoiding the quirks and extensions in the proprietary implementation you are using, your script should be highly portable to GNU bash and vice versa.

    Similarly, if you want to write a new shell, your best bet is to use the standard as the guide rather than to clone the behavior of the legacy Bourne shell.

    If you don't know what is standard and what is not, try the draft Single Unix Specification online.

    Search for ``shell command language''.

  47. Re:not not quite right by Cylix · · Score: 2

    The provided example for pointing out the problems with bash was just a really bad pick.

    You are not required to use teh shorthand initialization of a variable at export. It is a shotcut and that is all. It is not necessary to use that shortcut. So, while yes it does not behave exclusively like bourne, it is a frivilous point.

    I would have liked to have seen some better examples.

    --
    "You should always go to other people's funerals; otherwise, they won't come to yours." -- Yogi Berra