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?

249 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 Vanbo · · Score: 1, Insightful

      Why has this been marked down to -1?

      He just gave a valid solution.

      Include the FreeBSD source to /bin/sh with your product, have a simple script compile and install it on the Linux both someplace. Have your complicated install script use the new bourne shell for installing your app.

      I am hoping it was just accidentally marked down with the thought: "Oh no, someone is telling him to install FreeBSD, better mark it down"

      This is not what the parent was suggesting. Read carefully before blindly modding down based on seeing something you don't like...

      --
      VANBO
    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. 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).

    4. Re:Easy. by CutCopyPaste · · Score: 1

      Command.com rulez but no POSIX?

    5. Re:Easy. by MobyTurbo · · Score: 1

      FreeBSD's sh is actually ash, which is also not 100% compatable. Incidentally, Linux 0.95's (and if memory serves me correctly 0.99's early patch levels as well) two 5.25" disk boot/root combination used ash as it's shell to save space. "GNU-Linux" wasn't always so bash-centric. (Though it is true that the rest of the utilities were mostly GNU ones. :-) )

    6. Re:Easy. by the_2nd_coming · · Score: 1

      he is making an installer for Linux, how will installinf BSD help?

      --



      I am the Alpha and the Omega-3
    7. Re:Easy. by mrm677 · · Score: 1

      And why is this labeled a "Troll"? Can anybody explain how the Slashdot moderation works? Its seems like a load of shit to me.

    8. 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.

    9. 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."
    10. Re:Easy. by Geekboy(Wizard) · · Score: 1

      they say don't change to a dynamic root shell. If you pork your system, and when you go to fix it in single-user mode, if you only mount the / filesystem, and your shell requires libraries on the /usr filesystem, then it's a pain in the ass to fix.

    11. 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 Ninja_Gaiden_III_cut · · Score: 1

      None has to berate Linux, the kernel and sources were done by programmers in the reason of they had to do an exciting and cool thing.
      We have to get motivation and we have to do a new thing: Bourne shell for Linux.

      - The power is ours, the money is with MS.

    2. 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. Re:/bin/bash by MerlinTheGreen · · Score: 1

      Except Solaris 8!!!

  3. Try this out! by KGB+Kenny · · Score: 1, Informative

    Why couldn't you just write a small script that chooses what shell to use at the beginning?

    Say the following:

    File 1: Shell script to determine what *nix you are running

    File 2: Bourne shell script

    File 3: bash shell script

    File 1 determines whether to use Bourne shell script of bash shel script and passes it onto decided shell.

    Just a thought... hope I could be helpful!

    -theKGB 8)

    --
    Eric... You suck...
    1. 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.
    2. Re:Try this out! by knorthern+knight · · Score: 1

      > what's the first script to be written in, that it'll run on any unix?

      How about a simple if/elif chain ? Start with something simple like so...

      #!/bin/sh
      if (echo $SHELL | grep /bash)
      then
      echo Running bash;
      fi

      Throw in a whole bunch of "elif" cases for /sh, /ash, etc, etc.

      --

      I'm not repeating myself
      I'm an X window user; I'm an ex-Windows user
  4. Re:Not "sh" for Linux... by conway · · Score: 1

    You can easily compile and install bash on HP-UX.
    (I've done it in under 2 minutes.)
    Also, there are people committed to distribution of most popular GNU tools in binary for HP-UX and other commercial *NIXes, even though most compile and install from source without problems.
    (with the notable exception of gcc of course. Sheeesh -- try and get THAT to compile cleanly!)

  5. 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 psamuels · · Score: 1
      Is there any compelling reason (other than standards purity) not to just `rm sh; mv bash sh`?
      1. size - bash is big, which is not an issue on disk, but I do care how much memory my cron scripts need.
      2. efficiency - ash is noticeably faster than bash on my system. My "benchmark" is running a configure script generated by autoconf, after the settings have already been cached. (The first time you run configure, you'll be seeing 'gcc' efficiency more than anything else.) ash beats bash by something like 10%.
      3. dependencies - bash needs readline (for command line handling) and libdl (for loading extensions), and readline needs curses, ncurses, termcap or equivalent. If any of the above libraries breaks (botched upgrade, etc) you're screwed. You could conceivably compile bash staticly so the dependencies are built in, but then your binary is even bigger - see point 1.
      --
      "How can you claim that you are anti-crack, while still writing a window manager?" — Metacity README
    10. 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

    11. 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/
    12. Re:It's a non-issue. by sirinek · · Score: 1
      Not to be overly anal, but Solaris comes with the "standard" sh as /sbin/sh, and includes csh and ksh. As of Solaris 8, bash is included, but not as a replacement for the plain old sh. :)


      siri

    13. 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!

    14. Re:It's a non-issue. by Ninja_Gaiden_III_cut · · Score: 1

      Why a Bourne shell? It's a personal question, like choosing to use the right hand or the left hand. Left native Bourne as an option for whose need something less interpreter (I mean "don't syntax-forced"), most interface. Years ago open-source programmers venerate bash (supposedly binaries are less resource-hogs), however, they find that a OS' behavior induces actually (in the age of Pentium II) to a tad rely on processing power (well not Windows XP, hahaa...oh, I'm sorry) when supporting interfaces. Real demand is while running applications, (many programmed in C, dude) those pratically own a cpu(s). From me, nothing against a true Bourne shell for Linux.

    15. Re:It's a non-issue. by ink · · Score: 1, Troll
      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.

      So which is it that you people want? A POSIX shell or a Bourne shell? They are mutually exclusive. Bash and ksh are both POSIX shells, but the Bourne shell is most definately not. As far as I'm concerned, POSIX can go jump in a lake anyway -- but that's another rant for another day.

      --
      The wheel is turning, but the hamster is dead.
    16. Re:It's a non-issue. by Chandon+Seldon · · Score: 1

      There are no significant differences that would prevent a realistic sh script from being forwards compatible with bash as long as when the script was written everyone remembered that it might have to run under bash, so use "|" for your pipes instead of "^".

      --
      -- The act of censorship is always worse than whatever is being censored. Always.
    17. 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

    18. Re:It's a non-issue. by Ninja_Gaiden_III_cut · · Score: 1

      "your post was pretty hard to follow. Maybe you were questioning the fact that I wrote it in bash instead of C?"
      Yes, you find that I didn't mean what you did. I was talking strictly under the subject of the story "a real bourne shell for Linux".
      I was presenting the fact that a real Bourne should be implemented from a praxis standpoint.
      "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?
      Repeat, I was following the story.
      Not against scripts, but "why worry so much about creating a Bourne shell?": since bourne uses high-level programming it would be useful for certain users (pete-classic, you have to alternate bash and sh in the case you did present us) and it's easy to implement, then I just think here's a fuzz about something which it could be done before!
      I simply don't want to worry about lack of any option for my scripts.

    19. Re:It's a non-issue. by jcast · · Score: 1

      Bzzzt! Wrong!

      ``Embrace and extend'' is simply a short-hand for ``Embrace, Extend, Extinguish''. It's the ``extinguish'' part that's evil, because it locks you into a single vendor's proprietary implementation. Embracing standards is good; extending them is also good. That's how standards evolve. Extinguishing standards is evil. Stop spreading FUD.

      --
      There are reasons why democracy does not work nearly as well as capitalism.
      -- David D. Friedman
    20. 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."
    21. 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."
    22. Re:It's a non-issue. by Lazaru5 · · Score: 1

      If you were replying to the story then you should not have replied to a specific post. There is a Reply button at the very top of the comments for starting a new comment thread. Misuse leads to confusion.

      --

      --
      My comments and opinions completely reflect those of anyone and anything I am remotely associated with.
    23. Re:It's a non-issue. by Ninja_Gaiden_III_cut · · Score: 1

      Thanks ;)

    24. Re:It's a non-issue. by castlan · · Score: 1

      I would suggest using CSH for scripting. AFAIK it is almost as universal as SH. Under Linux I don't think that TCSH has as many CSH emulation bugs as BASH does for emulating SH.

      The C Shell was primarily intended to be a programming (scripting) shell as is evidenced by its semblance to C syntax. My old, very outdated NeXTStep installation showed that my CSH knowledge came in handy when BASH wasn't available. I don't know of any system that has a Bourne shell that doesn't also have a C Shell. It seems to fit your stated needs.

      C Shell syntax is different enough that there isn't much chance of accidentally writing an incompatible script.

      If this doesn't sufficiently address your needs, perhaps using NetBSD or another FreeBSD would provide more of a standard UNIX environment for development if portability is a primary concern.

  6. Re:/bin/bash - It all sounds so brutal by Anonymous Coward · · Score: 3, Funny

    hash bang slash bin slash bash

  7. 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 ethereal · · Score: 1

      Almost all installation boot disks seem to use ash, for pretty much the same reasons. I'm writing an installer right now an am using ash, in fact. For simple shell scripting, the extra size of bash just isn't worth it.

      --

      Your right to not believe: Americans United for Separation of Church and

    2. Re:Slackware uses ash for toolset by TicTacTux · · Score: 1

      If that is your personal opinion please declare it as such. Just because you haven't been able to get beyond YaST or linuxconf this doesn't mean all the rest is crap. Sure, Slackware is neither for the faint of heart nor for the illiterates...

      Use the source, Luke!

      --
      Use The Source, Luke!
    3. Re:Slackware uses ash for toolset by TicTacTux · · Score: 1

      And what, if I might ask, is the standard?

      --
      Use The Source, Luke!
    4. Re:Slackware uses ash for toolset by mrm677 · · Score: 1

      Grow up.

    5. Re:Slackware uses ash for toolset by doob · · Score: 1

      Whoops, you shot yourself in the foot there dincha? ^_^

      Scroll down till you get to the Distributions graph (as opposed to the Source graph I assume you looked at), and you'll see that RedHat is actually the most popular distro. But does this make it standard? That's a different question. Popular does not always mean good (as is amply demonstrated by chart music). Also interesting to note from this graph is that Slack is nearly as popular as Mandrake, 14& and 16% respectively.

      DISCLAIMER:
      I use Slackware at the moment, but when I can be bothered I'm going to switch to Debian, partly because it's the only major distro I haven't tried yet (but mostly 'cos my system is getting messy from all the stuff I've d'led/compiled, this is less a comment on Slackware and more a comment on my usage habits ^_^)

      --
      In the spoon, there is no Soviet Russia!
    6. Re:Slackware uses ash for toolset by buckeyeguy · · Score: 1

      In other words, Slackware runs "ash-backwards into the unknown"... ;)

      --
      I'd have a personalized plate on my car, but "toxic bachelor" won't fit into 7 letters.
    7. 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. ;)

    8. Re:Slackware uses ash for toolset by juhtolv · · Score: 1

      Slackware has ash version 0.2 and it really sucks.

      --
      Juhapekka "naula" Tolvanen - http://iki.fi/juhtolv
    9. Re:Slackware uses ash for toolset by Figment+E+Nygma · · Score: 1

      Slak is not dead. As for standards, (in this case RedHat vs Linux) there are many Microsoft users who would say "Linux is for elitists who just want to be different too". Simply dismissing a functional program/distro/OS (read ash/bourne/bash) because of its interpeted developmental status while it gets the job done effectivle is foolhardy. As for the RedHat argument I have the following to say: It is just as secure as Microsoft Products, its great im sure.. as long as you keep updating it. Show me a list of exploits for Slackware vs a list of exploitws for RedHat. Now take into account all the beginners getting into Linux because of RedHat under the pretense that Linux is a more secure system. And you have a lot prople who have a false sense of security and a clean unpatched RedHat install. Slak is not without its bugs, no system is. But I feel safe saying that it's default settings are indeed much safer. Different strokes for different folks. I think that small dismissive "Slak is dead, who cares" attitudes are the reason people stay with M$ (consider why Scottland had so much trouble with England back in the day... they couldnt work together) Dont get me wrong, RedHat is great in that its getting Linux out there, and known about, and thats what needs to be done... But IMHO its becoming another Bloated, M$-like, security holed system. My 2 cents. (or was that a dime?) :FMT

    10. Re:Slackware uses ash for toolset by Cryptnotic · · Score: 1

      The new Busybox defaults to using ash for its shell, iirc.

      --
      My other first post is car post.
  8. 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 glastonbur · · Score: 1

      Note: It's the Polish Linux Distribution, not the Polished Linux Distribution.

    2. Re:bash as /bin/sh by kloczek · · Score: 1

      PLD meand officialy .. PLD.
      Polished Linux Distribution or Polish Linux Distribution is only "hidden" meanung :)

    3. Re:bash as /bin/sh by Xane · · Score: 1, Flamebait

      odpierdol siê You Ameriocentric jerk. I don't think a country that manages to educate virtually all of it's population to the point of literacy and offers every citzen the RIGHT of free education up to and including a PhD is deserving of your scorn. Sure we charged out with horses against tanks 90 yrs ago but 180 yrs ago your capitol got razed by Canada, so what. Maybe your American education didn't bother to explain either of those two bits of history. Maybe you just insulted 40 millon people for being stupid and don't even know why you have that prejudice. What do Polskas know about Linux?...What do Americans know about the rest of the world? gupia pizda

    4. 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.
    5. 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

    6. Re:bash as /bin/sh by Xane · · Score: 1

      it means F*ck off the other is too nasty to post in eng.

    7. Re:bash as /bin/sh by Xane · · Score: 1

      whoever moded me down from two to flamebait screw you How is defending my nationality flamebait.

  9. 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
  10. 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 anfloga · · Score: 1

      Hear hear, some of these posts, MODDED UP (don't ask my why) are telling this guy that bash is backward compatible to sh, when it shows an example RIGHT IN THE STORY HEADER of how this isn't so (an incompatibility that I've run into myself, actually). Luckily, I use "question exchange", NOT ask slashdot, if I have a hard question I can't answer, because my question goes to the right people (not every lifeless "I think I know everything" on the face of the planet) and gets answered correctly more than half the time. Usually with insights and angles I didn't even consider.

      Erik

    2. 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.

    3. Re:Did you even read the complaint? by J4 · · Score: 1

      Luckily, I use "question exchange", NOT ask slashdot,

      QuestionExchange Close Down
      From: hgonzalez@questionexchange.com
      To: ts-xxxxxx@xxxxxx.net

      Dear John (xxxxxx),

      Due to the changing economic climate, and change of focus within VA Linux,
      QuestionExchange.com will be closing at the end of July. We thank you
      for your support and participation over the last couple of years and regret
      this necessary step.

      Should you have any question please contact us at: info@questionexchange.com.

      Regards,

      Hector Gonzalez
      Director - QuestionExchange

      QE wasn't bad, for a scam.

    4. 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.

    5. Re:Did you even read the complaint? by psamuels · · Score: 1
      Instead, why doesn't the article's poster come up with an example of a valid POSIX statement that breaks in bash

      typeset -u varname

      I don't know if it's strictly POSIX, but ksh supports this syntax for constraining a variable to auto-convert its contents to uppercase whenever you set it. This is the reason I can't use bash for my root shell in AIX - some poorly-written scripts don't have #! lines and rely on 'typeset -u'.

      --
      "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 psamuels · · Score: 1
      when it shows an example RIGHT IN THE STORY HEADER of how this isn't so (an incompatibility that I've run into myself, actually).

      What example would that be? All I saw was a vague statement to the effect that "bash has had weird bugs in the past". Doubtless it is true, but what is one supposed to do about that? All programs have had weird bugs in the past - you just have to tell your customers that your install script may not work if they're still using really old versions of bash -- just like you tell them that your software no longer works on HP-UX 8 or 9.

      To be clear, the syntax 'FOO=BAR; export FOO' works just fine on bash, so that can't be the "example right in the story header" you mentioned.

      Using ksh extensions to POSIX is just as bad as using bash extensions to POSIX - if a vendor script uses ksh-isms it may well work on all commercial Unices and not on Linux. But in that case I consider it the vendor's own problem.

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

      Er, wasn't the article about sh compatibility? How did this ksh peculiarity creep in?

    8. Re:Did you even read the complaint? by atrus · · Score: 1

      bash is NOT standard on FreeBSD. sh on FreeBSD is mostly POSIX.2 compatible (w/ Berkeley extensions), and they claim its similar to the Korn shell. The system defaults to giving tcsh (/bin/csh actualy, but its tcsh) as the default interactive shell. sh is only (by default) used for the scripts (/etc/rc and friends).

    9. Re:Did you even read the complaint? by psamuels · · Score: 1
      Er, wasn't the article about sh compatibility? How did this ksh peculiarity creep in?

      I know, I know. But in practice, this is sh compatibility, where /bin/sh is a link to ksh on AIX and to other POSIX shells on other Unices. As I've posted before, HP-UX doesn't even have a Bourne shell, to my knowledge.

      Upshot is, vendors writing install scripts generally use ksh features, so this is relevant. I agree that bash seems to be 100% back-compatible with the original Bourne shell, or at least I'm unaware of any counterexamples.

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

      To be clear, the syntax 'FOO=BAR; export FOO' works just fine on bash, so that can't be the "example right in the story header" you mentioned.

      I'm assuming the point was that in bash you can do 'export FOO=bar' rather than having to do 'FOO=bar; export FOO'.

      The answer to this is obvious. Just make sure when you write your script that you don't use the things that have been modified in bash.

      Any script written for sh should run in bash. When you write your script, just do it on a box with sh rather than bash. If you really want to do it on Linux, just pretend bash is sh and stick to the allowed syntax.

      --
      load "linux",8,1
    11. 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."

    12. Re:Did you even read the complaint? by Anonymous Coward · · Score: 1, Informative

      >> Re:Did you even read the complaint?
      > Yes. I did.
      > And it was nonsensical.

      It just appeared that way because you didn't understand it. Read it again and concentreate :-).

      The poster wasn't complaining of POSIX things not working in bash, he was complaining of non-POSIX things working.

      If you don't understand why this is important, you shouldn't be posting in this thread: Good software engineering requires the ability to QA software in an environment similar to that of your target platform. If your target platform has bourne shell only, and your development environment is linux, where the closest thing to sh is a bit different, then you're missing an element that's usually required to produce good software.

      Ironically, you yourself prove this point by complaining about the problems that come up when /bin/sh is relinked to ash because many scripts on your system have bash dependencies, in spite of their authors targeting them for sh (as indicated by the fact that they put #!/bin/sh in their headers).

      IMHO the solution to this real problem is to submit bugs to bash for any behavior that's incompatible with plain bourne when it's invoked as /bin/sh. Fixing bash should be simpler than writing a new bourne shell from scratch. Fixing all the scripts that depend on bash being broken, of course, would be another matter entirely, but these scripts could simply change to #!/bin/bash in their headers to confess to their bashness.

    13. Re:Did you even read the complaint? by the_code_poet · · Score: 1

      I have to support many platforms with these shell scripts. In addition to commercial variants of *NIX (Solaris, HP-UX, AIX) there are specific versions (distrobutions) of Linux that need to be supported.

      One such distrobution is Red Hat 6.1. The bash that comes with that distro is version 1.14.7

      Using that version, I inconsistantly stumble upon the "Can't reopen pipe to command substitution" bu g - which has to do with bash 1.x not being signal safe (SIGCHLD in this case).

      Of course bugs will crop up in any software, but as the size and features of any piece of software grows, we can expect to see more bugs with each feature. This is fine if you need the features that bash provide (which, i agree, are very nice). But if you are merely looking for stable Bourne shell compatibility, perhaps an alternative shell would be better suited for the task. I havent run exhaustive tests on ash, and im not sure its general deployment stature, but i know that ksh (pdksh) is not shipped in the base install for many linux distros.

      Its really a question of direction at this point. If the bash team are working on making a better interactive shell, and doing well i might add, then perhaps there arises a need for a simple POSIX Bourne shell. Writing to any shell other than #!/bin/sh is a bad idea for anything thats trying to be the lowest common denominator.

      I could write it in Perl, i could write it in C . insert your favorite language of choice here, but thats not the point.

    14. Re:Did you even read the complaint? by psamuels · · Score: 1
      One such distrobution is Red Hat 6.1. The bash that comes with that distro is version 1.14.7

      There's your problem, then - unless Red Hat 6.1 comes with ash or pdksh installed standard, I guess the answer to your original question is either "no, sorry, you'll just have to work around the bash bugs" or "better tell your customers to install ash or pdksh or bash-2.x" or "Red Hat 6.1 is too buggy to support".

      When you asked for "a real Bourne Shell for Linux", what you really wanted was "every Linux distribution shipping a reasonably bug-free shell as /bin/sh". This is a vendor QA issue, so what can one say? Bash 2.x seems to fit the bill, in any case, so your compatibility problems may go away in time.

      --
      "How can you claim that you are anti-crack, while still writing a window manager?" — Metacity README
    15. Re:Did you even read the complaint? by Furry+Ice · · Score: 1
      At first this just sounds like trolling, but I think he's got a point. If you're writing a commercial software installer, you undoubtedly have test machines in-house where you could test your script as well as the application.

      If you're writing free software, you've got a bit more of a challenge, but I'd argue that you might as well just put a #!/bin/bash at the top of your script. If you're writing free software, it's pretty safe to assume that the person installing it will have bash...

    16. Re:Did you even read the complaint? by Cryp2Nite · · Score: 1
      Why the fuck would you EVER be writing a shell script on a box other than the one you are going to run it on!?

      I took your advice and SSH'ed into a few boxes I have around.
      How many of these are distibuted as third party software/ ports/ packages?
      Never mind why, it's quite common.

      Redhat:
      file /usr/bin/* |grep "Bourne shell script text executable"|wc
      250 1500 21500
      FreeBSD:
      file /usr/local/bin/* |grep "Bourne shell script text executable"|wc
      31 186 2666
      NetBSD:
      file /usr/pkg/bin/* |grep "Bourne shell script text executable"|wc
      85 510 6290
    17. 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
    18. Re:Did you even read the complaint? by Reikk · · Score: 1

      He has to use something else. Linux doesn't come with what he wants because most linux distros don't care about compatibility with HPUX.

      Here are a few possible solutions to the problem:

      1) See if ash works with the script
      2) Install bash on the HPUX systems
      3) Write it in another shell the systems have in common
      4) Rewrite it in perl or python
      5) Write a simple shell script (that of course would work on both sh and bash) called checkos.sh which determines the operating system,then calls the appropriate script for that system.

    19. 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
    20. 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
  11. 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 */
    1. Re:Ash by kloczek · · Score: 1

      Or try pdksh:
      $ ls -l /bin/ksh
      -rwxr-xr-x 1 root root 171164 pa? 20 03:29 /bin/ksh

    2. Re:Ash by quigonn · · Score: 1

      Yes, dietlibc definitely rules. Unfortunately quite a lot of applications break when you link them against it. :-(
      But I'd support a dietlibc-only system. Maybe with embutils? :)

      --
      A monkey is doing the real work for me.
  12. 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.

  13. 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.

    1. Re:As to distro startup scripts... by kaisyain · · Score: 1, Interesting

      Strange, I remember complaining on debian devel about four or five years ago about this -- about how debian assumed that /bin/sh was bash. Everyone told me to shut up and go away because it was obvious that /bin/sh was bash on linux. I'm glad to hear they've finally decided I was right :-)

    2. Re:As to distro startup scripts... by ggeens · · Score: 1

      If you install ash on Debian, you have the option to install it as /bin/sh. It's a low-priority option, use dpkg-reconfigure ash if you never saw this.

      If you bump into a problem because of this setting, you should report it as a policy violation.

      --
      WWTTD?
  14. 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

  15. ksh: I built a ksh93 rpm by dananderson · · Score: 1
    Just so you know, I built a ksh93 (the Korn shell) rpm. It's at http://dan.drydog.com/packages.php

    For information on Korn shell, see http://www.kornshell.com/

    With ksh, you can more easily interoperate with commercial UNIX systems, which now a days all come with ksh.

    1. Re:ksh: I built a ksh93 rpm by jbgreer · · Score: 1

      So, how are you complying with the AT&T license? Specifically your obligation to ensure that the recipient enters into the agreement with AT&T?

      * YOUR OBLIGATIONS

      1. If you distribute Build Materials (including if you are required to do so pursuant to this Agreement), you shall ensure that the recipient enters into and duly accepts an agreement with you which includes the minimum terms set forth in Appendix A (completed to indicate you as the LICENSOR) and no other provisions which, in AT&T's opinion, conflict with your obligations under, or the intent of, this Agreement. The agreement required under this Section 4.1 may be in electronic form and may be distributed with the Build Materials in a form such that the recipient accepts the agreement by using or installing the Build Materials. If any Additional Code contained in your Build Materials includes Software you obtained under license, the agreement shall also include complete details concerning the license and any restrictions or obligations associated with such Software.

      --
      The Norton Anthology of English Literature, 4th Ed., Vol 2
    2. Re:ksh: I built a ksh93 rpm by dananderson · · Score: 1

      Solaris (and I believe HP-UX and AIX) have dtksh (part of CDE), which is ksh93-based with some GUI extensions. That can be used for a ksh93 platform.

    3. Re:ksh: I built a ksh93 rpm by dananderson · · Score: 1
      Good point. That does, however, only apply to the source RPM, not the binary RPM.


      I notice Slackware and Debian also have ksh93.

  16. What's the problem? by reynaert · · Score: 1

    I've read the list of differences in the FAQ. It's just a big list of extensions to the Bourne shell. It doesn't list any incompatibilities (except for a couple of obscure missing features which you probably shouldn't use anyway). If you write something in standard Bourne syntax, there should be no problems with Bash.

    If you, on the other hand, test it with Bash, and then assume it will run under any other Unix... Well, you shouldn't do that with GNU software :)

  17. Re:What vacuum are you living in? (ksh and zsh) by anothy · · Score: 1
    i'm almost afraid if i comment here your head'll explode...
    ...ksh, the unquestioned pinnacle of scripting shells...
    unquestioned, huh? go tell that to the bash guys. or the ash guys. or, heck, me. ksh is pretty good, but it's certainly not the unquestioned anything, and i'd question whether it's the best scripting shell available (even using a narrow definition of shells that exclude things like perl).
    ...zsh, the unquestioned epitome of user shells?
    again, tell that to the bash folks, or the dozens of other user shells out there. personally, i love rc, for both scripting and interactive use. doesn't have all the features of the others, but is much less complex, much smaller, and simpler and more consistent to use. but the point is that there's no unquestioned shell for anything.
    not to mention the fact that your "suggestion" totally ignore the guys problem: writing a cross-platform install script. zsh is totally non-standard, so that's out. ksh is pretty common, but not totally common, and is installed as different things in different places. there's definatly a place for a standard (you linux guys remember those, don't you?), and, for the time being, bourne shell's it. so either linux gets with the standard program, or it continues to be a pain.
    --

    i speak for myself and those who like what i say.
  18. Re:2nd hit on Google by VA+Software · · Score: 1

    It suggests

    Ksh93 may be had, precompiled for Linux, via www.kornshell.com

    Which another poster in the thread has said works.

    Also, it shows that lots and lots of people have asked the same question already - and got similar answers to the answers posted here. Doing a bit of research is quicker than submitting an ask /.

    --

    ---
    http://slashdot.org/moderation.shtml
  19. 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?
    1. Re:ash (for debian, at least) doesn't work by psamuels · · Score: 1
      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...

      Are these scripts distributed with Debian? If so, file bugs - this sort of thing is Not Allowed. If they are third-party, same thing - file bugs, although a third-party script vendor may not care as much....

      --
      "How can you claim that you are anti-crack, while still writing a window manager?" — Metacity README
  20. 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
  21. Debian uses ash. by BubbaFett · · Score: 1

    Debian kernels are now compiled with initrd support. They use ash for their kernel boot scripts. I'm guessing this is because of it's size.

    1. 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
    2. Re:Debian uses ash. by psamuels · · Score: 1
      Debian kernels are now compiled with initrd support.

      Now compiled? They have had initrd support for as long as I can remember (1996? 1997?).

      They use ash for their kernel boot scripts. I'm guessing this is because of it's [sic] size.

      Boot scripts (what is a "kernel boot script"?) can be in either bash or sh, but if they declare #!/bin/sh they must not use any non-POSIX-isms. The installation floppies use ash, because of its size. Recently someone proposed using the built-in shell from Busybox, but that may not happen because of robustness / compatibility.

      --
      "How can you claim that you are anti-crack, while still writing a window manager?" — Metacity README
    3. Re:Debian uses ash. by BubbaFett · · Score: 1

      Now compiled? They have had initrd support for as long as I can remember (1996? 1997?).

      Well, maybe they have, I don't know. I've never tinkered with it, but the packages in testing now depend on initrd-tools, which in turn depend on ash.

    4. Re:Debian uses ash. by psamuels · · Score: 1
      the packages in testing now depend on initrd-tools, which in turn depend on ash.

      They've always used an initrd for installing (so the kernel images have to be compiled to support initrd) - the difference is that now I believe Debian plans to use an initrd for regular hard disk booting as well. Hence the need for initrd-tools.

      Red Hat and other distros already do this. The reason is that your root partition may be on a disk which is inaccessible without particular drivers for IDE or SCSI chipsets, and including all possible IDE and SCSI drivers in the one distributed kernel image is thought to be prohibitive. Debian compiles all SCSI drivers in anyway, whereas Red Hat builds an initrd to load the needed module(s) while booting.

      Some distros take a third approach, and distribute several different kernel images to cover common SCSI drivers. Debian sort of does this too, with its Hedrick-IDE-drivers kernel image.

      --
      "How can you claim that you are anti-crack, while still writing a window manager?" — Metacity README
  22. 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 mikec · · Score: 1

      I'm curious. What, exactly, is the Linux packaging system?

      -mike

    2. 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.
    3. 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
    4. 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.

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

      tgz. rpm. No, wait, .deb. Er, that is, .tar.bz2. Or was it .zip? Dang, I had it on the tip of my tongue - cat <<EOF? .Z? A, now I have it: x-application/linuxpackage!

      Use the source, Luke! (sic! ed.)

      --
      Use The Source, Luke!
    6. 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.

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

      Solaris packages are just a collection of files and a few config files that tell the system where to put the files. If you want to do anything more complex than "Put file X in /bin" you have to write start and finish scripts for the package.

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

      The problem is that these install programs also use shell scripts to perform their magic. The issue here is that these install scripts must be portable. Unless you want to install a shell along with the application you must rely on the syntax of /bin/sh. IOW can you guarantee that it won't break for the real bourne shell?

      Further, are the shells from HP, AIX SGI, Sun etc really 100% identical? I am have no way of knowing if the Bourne shells out there are really 100% compatible. Its been a long time since Mr. Bourne wrote this shell and I don't know if all these companies have kept the code unmodified when they distribute it in their own OS. I suspect not! It only takes one minor misinterpretation of some subtle point on the part of the shell implementer to cause a problem like this.

      If someone would implement a truly Bourne compatible shell licenced under the GPL then we could have a consistent shell to write scripts for and maybe eventually weight of numbers would cause this shell to become the defacto standard. I have been thinking of doing this for some time, perhaps starting with ash.

    9. 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.
    10. Re:And which "real Bourne shell" would that be? by Jorrit · · Score: 1

      And what if you only have target to one distribution? I only have Mandrake on my PC and I'm not planning to install another distribution. I want to target linux, not a distribution. Sorry but this is absolutely unacceptable solution. Unless linux has a non distribution specific packaging solution then this is not an option.

      Just IMHO of course.

      Greetings

      --
      Project Manager of Crystal Space (http://www.crystalspace3d.org). Support CS at http://tinyurl.com/cb3x4
  23. Not much choice, is there? by mikec · · Score: 1

    You have to use /bin/sh and test on all platforms. There isn't anything else you can rely rely on finding on all distributions. Yes, there are probably slight differences between what purports to be /bin/sh on various platforms, but I can't imagine it will be very hard to write a script that runs fine under all of them---just avoid the dark corners.

    Suggestions for other shells (ash or whatever) that might be better are pointless for your purposes because you can't rely on them being there.

  24. Bash versions with bugs by Croooow · · Score: 1

    I know from experience that (some?) 1.x Bash versions have a bug in the getopt builtin. The bug seems to be fixed in 2.x versions (not sure what version fixed it). There is a workaround for the bug, but it breaks portability of the script. The workaround also causes the script to break for fixed versions of Bash.

    1. Re:Bash versions with bugs by psamuels · · Score: 1
      I know from experience that (some?) 1.x Bash versions have a bug in the getopt builtin.

      That's unfortunate. I haven't used bash 1.x for a very long time, so I can't confirm or deny, but I think the reasonable thing to do is tell your customers you don't support bash 1.x as /bin/sh.

      There is another bash bug (or at least difference with bash 2.x - I assume the bug is in 1.x) in its handling of $IFS. This one bit me last year. I submitted a patch for the Linux kernel which relied on a feature added by another user which hadn't been tested in bash 1.x (prior to my patch, the feature had never actually been used).... That's how I found out that Red Hat 6.0 apparently still shipped with bash 1.14, so we added a workaround that didn't use $IFS.

      --
      "How can you claim that you are anti-crack, while still writing a window manager?" — Metacity README
  25. Linux ash == BSD sh? by BubbaFett · · Score: 1

    From what I can tell from the documentation and man page, ash is just BSD's /bin/sh. Do the BSDs use GNU Bash, assuming the admin wants Bash on the system at all?

    1. Re:Linux ash == BSD sh? by The+Ape+With+No+Name · · Score: 1

      Bash is a pkg to be added later on FreeBSD. You start with /bin/sh and csh. For religious reasons, I make the first order of the day after building a FreeBSD box:

      # pkg_add -r bash

      It currently installs bash2.05. I have users who are Linux people that wanted bash. I use it meself now.

      From the sh man page:
      The current version of sh is in the process of being changed to conform with the IEEE AStd 1003.2 ("Posix.2") specification for the shell.

      No mention of ash anywhere in the man page, but it is obviously not a pure sh.

      --
      Comparing it to Windows will be a moot point, since El Dorado is going to have a 40% larger code base than XP.
  26. No other OS? by Doktor+Memory · · Score: 1

    No other OS puts bash under /bin.

    Except for Solaris 2.7 and 2.8. Ahem.

    --

    News for Nerds. Stuff that Matters? Like hell.

    1. Re:No other OS? by larien · · Score: 1
      Ahem indeed:
      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.
      2. bash was only introduced into Solaris as of Solaris 8 along with zsh, apache, gzip and some other GPL stuff.
      3. /bin is actually a symlink to /usr/bin, so technically it doesn't put it under /bin
      Oops, better put on the asbestos now :)
    2. 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.

    3. 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.

    4. Re:No other OS? by OmegaDan · · Score: 1, Flamebait

      bash maybe in an addon pack .. but the default installs of 2.7 and lower definatley had no bash ... Infact, a default 2.7 install is just *baren* as im sure your aware. 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

      (to me this is:
      * mount /usr/local (network),
      * set paths so usr/local software overides the default solaris stuff (a couple of the utils like tar are strange)
      * install bash/ssh (and libs)/update tcsh (ok, ssh isn't necessary, but its only a couple extra keystrokes)

      Now your machine is on the network, you've got bash and the paths are setup to use gnu utilities and not those fucked up ones that come with solaris -- *now* your ready to run your auto-configure script.

      Why can't the script setup this by hand? Well, you need bash as an interpreter cuz the sh it comes with is pretty fucked up -- and theres *no* way to get the script on the computer -- recall until recently sparc machines *didn't come with floppies* hell, most of our ultra1's (don't laugh!) don't even have cdroms (I have a spare cdrom I drag from machine to machine when I need to install (but you've gotta open up the machine anyways to set the jumper allow the installer to flash the bios ...)

      I guess I could make a bootstrapping cdrom ...

    5. Re:No other OS? by cdh · · Score: 1

      What? The sh that Solaris ships with is messed up? Oh my...It's the most standard one there is. bash is what's messed up. I've done a lot of "porting" of "Unix" programs that are so totally linux centric that it's not even funny. The people who try to write scripts almost always do so by saying /bin/sh when they really want to use bash. Any commercial Unix (Solaris, IRIX, AIX, etc.) has separate sh and bash. Solaris 8+ has bash as an option:

      {cdh@sunray} 10:23pm (~) > pkginfo |grep bash
      system SUNWbash GNU Bourne-Again shell (bash)
      {cdh@sunray} 10:23pm (~) >

      It even puts it in /bin. Just use /bin/bash if you mean bash, otherwise just stick to the normal sh semantics, it makes life much easier for everybody else.

      ssh shouldn't be "optional", it should always be put on. I am upset that Sun (and most other commercial Unix vendors) don't bundle ssh, but then again, we always install a different version of perl than the Solaris default one.

      Finally, learn how to jumpstart your machines, there's absolutely zero need to lug a CD-ROM around (and not having a CD-ROM in the first place is not Sun's fault, but rather your employer's fault, it's definitely an option on the Ultra 1s). We just jumpstarted 20 machines this week, total time for then installs was less than 6 hours. AND we did it remotely thanks to serial consoles (which Intel boxes still can't do) which gets us to PROM level. Very nice...

    6. Re:No other OS? by OmegaDan · · Score: 1

      I meant ssh was optional in the sense it wasn't required to run install scripts ... I definatley disable all rsh's/telnets on my machines ... which leaves ssh the only option :) Some other departments have learned that the hard way...

      as for the cdroms, yeah, my employer has a tendancy to spend *ALOT* of fucking money and skimp on the details ... We have a 40,000$ media100 system (kinda device you'd edit a sitcom on) and *it can't encode mpegs* cuz we didn't get the 1000$ copy of media cleaner to do that :)

      We've got a 37,000$ sgi octane (we got ripped:)that was very expensive and has been used for nothing more then a terminal for the last 4 years cuz we don't have the compiler for it (costs extra)...

      unfourtnatley these are decisions that are out of my control :) I have to work within the situation thats handed to me ... and in the meantime, look for a better job :)

      but yours is good advice :)

    7. Re:No other OS? by khuber · · Score: 1

      Moderators: here's a nickel, buy a clue.

      As the anonymous followup says, Solaris is
      the distribution, and SunOS is the kernel.
      (like RedHat is a distribution and Linux
      is a kernel)

      -Kevin

    8. Re:No other OS? by larien · · Score: 1
      Sheesh, some people can't take bit of a joke...

      Yup, the breaking of the numbering scheme was dumb, especially done at the last minute as it was (ISTR the announcement of the change was about 2-4 weeks before the release). However, while I can forgive '2.7' as it was called that during Beta, there has never been a Solaris 2.8.

      Having never bothered that much with MU packs (I just tended to get the patches I needed individually) I dunno about bash appearing in one. If it did appear, I completely missed it and I've tended to find stuff like that on newsgroups. Solaris 7 wasn't too bad in any case; it was a heck of a lot better than 2.6 in any case (UFS logging, pkill, 64-bit kernel etc).

      Yup, the /bin /usr/bin nitpick was probably being silly, but it was meant as a joke.

    9. Re:No other OS? by Tsar+cr0bar · · Score: 1

      Uh, Intel boxes can do serial consoles either with a PC Weasel, or a mobo supporting it.

    10. 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.

    11. Re:No other OS? by Pyrrus · · Score: 1
      3. /bin is actually a symlink to /usr/bin, so technically it
      doesn't put it under /bin


      split hairs all you want, the comment was about
      starting scripts with #!/bin/bash, so technically in /bin
      or not, it will execute the script properly when
      you tell it that it is in /bin
    12. Re:No other OS? by t · · Score: 1

      Do you realize that those cards cost like $350? And what mobo's where you thinking of? I wish the shuttle had this capability.

  27. Re:/bin/bash - It all sounds so brutal by TicTacTux · · Score: 1

    ...been to thinkgeek lately?

    Use the source, Luke!

    --
    Use The Source, Luke!
  28. Re:How linux is still an inferior desktop OS by Anonymous Coward · · Score: 1, Insightful

    except on the *NIX that is growing the fastest, Linux, KDE is still include as default in every major distrobution except for RedHat. It is also default in the second largest *NIX, FreeBSD.

    Face it, gnome is dead. all of the gnome developers should switch to KDE or else their work will be at loss.

  29. 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 Jay+Bratcher · · Score: 1

      * redirection to/from compound commands causes sh to create a subshell

      Actually, that is quite a show stopper - consider for a minute what happesn when you spawn a new shell. Does your profile get sourced? What happens to any environment variables you set in the new shell? I have seen many scripts which rely specifically on this feature, and therefore will not work in ksh or bash.

    2. Re:Which direction are you worried about? by Anonymous Coward · · Score: 1, Informative

      > I think that there is some confusion here.

      Indeed there is. In fact, you seem quite confused :-)

      > Things that you can write under bash that
      > won't work under sh. So what?

      So what? Some people like to test their software. I know, it's an old fashioned idea, but let's try to humor those quaint folks in this thread.

      Having things work under bash that won't work under sh is exactly what makes it hard to test sh scripts in an environment that only has bash.

      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.

    3. Re:Which direction are you worried about? by psamuels · · Score: 1
      Actually, that is quite a show stopper

      Yes, any script that sets variables inside a compound pipeline and expects them to either (a) persist outside the pipeline or (b) not persist will be non-portable.

      Any time you set a variable within a pipeline, use () around the pipeline; then the behavior is well-defined - variables will never persist outside the pipeline.

      Does your profile get sourced?

      It shouldn't. The subshell is not a newly executed copy of /bin/sh, after all, just a fork().

      --
      "How can you claim that you are anti-crack, while still writing a window manager?" — Metacity README
    4. 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

  30. Re:a real bourne shell by psamuels · · Score: 1
    is it possible to scale linux down, put (insert the most user-friendly windowmanager here) in it, and keep all those server stuff (appache, bind etc.) out put it on one cd, make an easy installer with good hardware detection, make a framework that 3rd party software vendors can work on

    The one requirement you forgot was "and get it noticed by the media so that people will even know it exists". There are scores of Linux distributions, and more than a few were created with exactly these goals (SEUL for one), but you'll never hear about them on CNET.

    ah ya, and dont forget to write a script that makes the delete and backspace buttons work under every terminal-emulator.

    Use Debian, they actually have a "delete/backspace policy" that covers this. Of course, all bets are off when you use said terminal to telnet to a non-Debian system - that's a problem you just can't solve without cooperation from vendors....

    --
    "How can you claim that you are anti-crack, while still writing a window manager?" — Metacity README
  31. 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.
  32. 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
  33. Never thought I'd see it. by GISboy · · Score: 1

    bashing microsoft, I believe.

    But bashing bash?

    As a current tcsh user under OS X I feel the need to be Bourne again.

    i wonder if there is a bashdot.org..I'll go look.

    (j/k)

    --
    If it is not on fire, it is a software problem.
    1. Re:Never thought I'd see it. by TomK32 · · Score: 1

      indeed there's bashdot.org
      but I think dashdot.org is more likely what you prefer

      --
      -- just a geek - trying to change the world
    2. Re:Never thought I'd see it. by moof1138 · · Score: 1

      I honestly don't see why people like bash so much, but being one of those zsh users, to me bash seems so lacking in useful features comparatively. zsh on OS X can be made to behave just like bash if you want that behavior. By default it is useless, but once you've set up a good .zshrc it sings. Take a look at zsh.org for more info.


      Interestingly Mac OS X uses zsh for its sh emulation, and Jordan Hubbard was on the darwin lists explaining that they are planning to move to bash for sh emulation since it is more lightweight and seemed to help performance a lot for sh intensive things like configuring, and making certain software packages where lots of instances of sh were called up. I was hoping they would use FreeBSD's sh or ash or something more lightweight than bash, but bash is still better than zsh for sh emulation.

      --

      Hyperbole is the worst thing ever.
  34. (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 julian7 · · Score: 1

      Maybe the copyright notice bothers the poster. BTW writing portable shell script is a hell if you have only bash. Just look at an output of autoconf and have a laugh over it:

      In bash you cannot do this:

      test -d "$dir" || ( echo "$dir doesn't exists"; exit 1)

      Thus, autoconf creates this kind of exit:

      test -d "$dir" || { { echo "$dir doesn't exists" > }; echo "$dir doesn't exists" > { (exit 1;) exit 1; }; };

      Lovely, eh?

    2. 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
    3. Re: (Sorry, a little clarification) by julian7 · · Score: 1

      Did you read sh(1) man page? It says that in () everything occurs in a subshell, except exit. BTW I don't say autoconf should be supported on any platform, just autoconf scratches it's head with a keyboard when it itches.

  35. 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
  36. Will the Real Bourne Shell Please Stand Up? by John+Hasler · · Score: 1

    "would anyone out there be interested in writing a real Bourne Shell for Linux?"

    First you will have to tell us what a "real" Bourne shell is. It's not as if there is a standard.

    You might or might not like ash. It is much smaller than bash, but on the other hand it tries even harder than bash to be POSIX compliant.

    --
    Warning: this article may contain humor, sarcasm, parody, and perhaps even irony. Read at your own risk.
  37. 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.

  38. Re:Not "sh" for Linux... by Anonymous Coward · · Score: 1, Insightful

    The problem is that "/bin/sh" SHOULD be the Bourne shell, or at least a 100% Bourne-compatible shell, on UNIX systems.

    bash is not 100% compatible. If I want bash, I use #!/bin/bash, but if I use #!/bin/sh and write Bourne shell code, I expect it to not break.

    If bash is used as /bin/sh, some scripts written for Bourne shell (= /bin/sh) do not work, and that's a big problem.

    /bin/sh is the Bourne shell, /bin/bash (or /usr/bin/bash, or whatever) is bash. Asking vendors to replace /bin/sh with bash is not reasonable since bash isn't fully compatible with the Bourne shell. Asking them to include bash and install it as /usr/bin/bash however, is quite reasonable.

  39. test -e by isj · · Score: 1

    I have encountered errors with the built-in test with -e tests, eg::
    [ -e file.foo ] && something
    The problem is really hard to reproduce. It has occurred on both the bash delivered with Solaris 8 and HPUX 11i, but not under Linux. Strange.

    Has anyone else seen this?

    1. Re:test -e by J'raxis · · Score: 1

      Well, first off, what kind of errors do you mean? It actually breaks (as in an error message or even crashing the shell) or it just doesnt work?

      Does the analogous
      if [ -e "file.foo" ]; then
      something
      fi

      also have the same problems?

    2. Re:test -e by isj · · Score: 1

      Well, it just fails as if the file does not exist.

      And yes, the "if [ ... ] then .. fi" fails too.

      I have not seen a pattern in the behaviour. Most of the time it works, sometimes it fails. The "-f" always works.

    3. Re:test -e by Quickening · · Score: 1

      heh, I had that error too - on ksh on AIX4.2x ! Very irritating random failure; I had to replace all my tests with ls's.

      --
      tcboo
  40. 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.

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

      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.

      Output to two files? tee(1) is your friend. Input from two files? Well, I'll admit you have me there. If they're text files, I usually cat them and pipe them into the program over STDIN. I suppose one could do that with non-text files, I just haven't tried.

      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...

      --
      Without you I'm one step closer to happiness without violence.
    3. 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.

    4. Re:bash SUCKS, csh ROCKS! by psamuels · · Score: 1
      Output to two files? tee(1) is your friend.

      Only if you want to output the same text to two or more files, at the same time.

      What if you want to have four output files from the same script, and output various things to each file? There are two ways to do this. The first is to use ">>file1" at the end of each command that outputs to the first file, ">>file2" at the end of each line that outputs to the second file, etc. This is cumbersome, and generates a lot of extra file open/close calls.

      "So it's inefficient, who cares?" Well, it's also incorrect. It breaks when writing to a named pipe, for instance, because the reader of a pipe can get EOF on reading if you don't leave the pipe open the whole time.

      More importantly, this method doesn't work so well when getting line-by-line input from a file. If you use '<file1' on a command, it will redirect input from the beginning of 'file1' every time. There is only one input file (stdin) that stays open between command blocks, and the shell programmer has no control over what file that is.

      The second way is to open each file the way you would in a real programming language. In Bourne shell, that is the 'exec' command, as in 'exec 4>some_file', which opens descriptor 4 for output to 'some_file'. To close descriptor 4, use 'exec 4>&-'. Then to write to it, use 'some_cmd >&4'.

      Input works the same way except with '<' in place of '>'.

      In csh, none of this is possible - you have to explicitly redirect each command to or from your input or output.

      If they're text files, I usually cat them and pipe them into the program over STDIN.

      Try writing a mail filter that takes a mail message on stdin and reads a configuration file to decide what to do. In csh, this is at best really awkward. Your 'cat' solution won't work here. Once I managed it by actually saving stdin (the message) to a temp file, then re-execing my filter with a magic command line argument that meant "look, the message is in xxx file, stdin is your config file" and acted accordingly. It worked, but I'm not proud of it!

      (Technically, I did the above in Bourne shell, but I was thinking like a csh user because I didn't know Bourne shell well enough at the time to know about redirecting with 'exec'. This was, perhaps needless to say, many years ago.)

      --
      "How can you claim that you are anti-crack, while still writing a window manager?" — Metacity README
    5. 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.

    6. 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.

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

      Some people use tcsh interactively but program with sh/ksh/bash/etc. I somewhat understand this mentality, but it's not for me. Because to me, there is not always a clear line between "interactive use" and "programming".

      Have you ever typed, on a single command line, a mini-script to tar up every directory larger than xxx kilobytes, not counting *.o files (so you can't just use du), naming them ../{dirname}.tar? Have you ever written an "alarm clock" on a single command line that clears the screen, then prints out hours:minutes:seconds on a fixed line, counting down to when it will start beeping at you by looping through echo ^G and sleep 1, but meanwhile letting you get a nap?

      Heck, maybe it's just me. But when I need to do stuff like that, I would consider it a hassle to fire up an editor, write a script, save it, chmod it +x, run it, and delete it again. I would also consider it a hassle to make it run to multiple lines on my command line, because command line editing gets so much harder. No, the 600-char single line is the way I get certain things done.

      csh would make my life a lot more difficult in this regard, because you can't do arbitrary conditionals and loops on a single line. I agree with your shell functions and redirection woes, but this limitation is another reason I avoid csh/tcsh interactively as well as for scripts.

      --
      "How can you claim that you are anti-crack, while still writing a window manager?" — Metacity README
    8. Re:bash SUCKS, csh ROCKS! by MaufTarkie · · Score: 1

      Try writing a mail filter that takes a mail message on stdin and reads a configuration file to decide what to do.

      Well, I'd probably use perl or python if I were going to do something like that. At any rate, thanks for your tips -- I'll keep them in mind the next time I need to do something more complex than tee and cat (which happens more often than not).

      --
      Without you I'm one step closer to happiness without violence.
  41. Re:How linux is still an inferior desktop OS by MMMMMMMMMMMMMMMMMMMM · · Score: 1
    MS-DOS 1.0 was released August, 1981.

    Bash 1.0 was released Jun, 1989.

    Do the math. You are wrong, sir.


    MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMM

  42. 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

    1. Re:Portable Shell Programming by Kamion · · Score: 1

      HP-UX does as well.

      I work in a shop where HP-UX and SOLARIS systems use a common scripting interface across all applications, which just happen to be written ksh.

  43. Red Hat != Linux by John+Hasler · · Score: 1

    "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"

    Debian policy requires that scripts that use bashisms (that is, non-POSIX features) use #!/bin/bash and not #!/bin/sh. The goal is to be able to link any POSIX shell to /bin/sh and not have anything break. For my own scripts (some of which have run to 1000 lines) I confine myself to sh features documented in my old copy of Kochan and Wood.

    --
    Warning: this article may contain humor, sarcasm, parody, and perhaps even irony. Read at your own risk.
  44. You know what they say by Man+of+E · · Score: 1, Redundant

    Bourne a shell, always a shell...

    --
    Ceci n'est pas une sig
  45. Re:Not "sh" for Linux... by j-pimp · · Score: 1

    If I want bash, I use #!/bin/bash, but if I use #!/bin/sh and write Bourne shell code, I expect it to not break.
    Funny, if I want to use bash I use #!/usr/local/bin/bash. Oh wait thats cause I use FreeBSD, a unix with a bourne shell.

    --
    --- Justin Dearing http://www.justaprogrammer.net/ We're just programmers.
  46. Re:a real bourne shell by mangu · · Score: 1, Flamebait

    Yeah, and put ONE and ONLY ONE manager for email and ONLY ONE for news and ONLY ONE for irc and ONLY ONE for icq? If you are a guru and want choice, well, then go and download your alternative package from the net, but do not force newbies to choose between mutt and pine and whatever.

    And put an expert system for running tksysv that doesn't fuck up the order in which daemons must be started up and shut down. And DEBUG that fucking apt-get thing, so one can update a system. And don't invent a buggy GRUB when LILO is working just fine.

    I've tried almost every distro since Yggdrasil came along, and I believe in the good old school that says one must debug the fucking thing before putting more "improvements" and "features" in.

  47. Korn shell? by tsprad · · Score: 1

    Do any of your target platforms not have ksh88? PDKSH is rock solid, and the few incompatibilities are insignificant and documented. I believe OpenBSD uses it as /bin/sh. I've been using it for years and highly recommend it.

    Alternatively, the FreeBSD /bin/sh could probably be ported to linux pretty easily. I believe it's derived from ash. I don't think it's perfectly compatible with Bourne's original, though.

  48. 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."
    1. Re:use perl by psamuels · · Score: 1
      for an installer, I'd say it wasn't crazy idea;
      Unfortunately, while /bin/sh is pretty much a standard location, you can't rely on Perl being /usr/bin/perl, or /usr/sbin/perl (!), or /bin/perl, or /usr/contrib/bin/perl, or /usr/freeware/bin/perl (I've seen all of these in various Unix vendor installs) or /usr/local/bin/perl. You have to find it at runtime, which means you still need a shell script to invoke your perl script. Which is awkward - you need two files, or a here document which is even worse.

      And no, they do not all come with Perl 5. HP-UX 11.00 still has Perl 4.0.36, in this day and age! I think Digital Unix had Perl 4 as well (I don't know when or if Tru64 switched), and I believe IRIX only switched to Perl 5 a couple years ago. AIX did not come with Perl at all until either 4.3.2 or 4.3.3 (the latest is 4.3.4, not counting 5L).

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

      Right on! With two caveats: Perl is large(r than bash) and Perl isn't always installed in the same place on all platforms [ not that this can't be changed by rolling it yourself. ] Oh... and a few vendors out there are behind the current stable perl version quit a bit.

      --
      The Norton Anthology of English Literature, 4th Ed., Vol 2
    3. Re:use perl by Chandon+Seldon · · Score: 1

      Use the env hack:

      #!/usr/bin/env perl

      --
      -- The act of censorship is always worse than whatever is being censored. Always.
  49. csh needs to be taken out and shot. by Dom2 · · Score: 1

    Hello, what planet are you on? The csh looks nothing like C. The syntax is clumsy and inflexible. See Csh Programming Considered Harmful.

    Not only that, but csh is actually older than the bourne shell!!! It was derived from 6th Edition Unix, the bourne shell was new in 7th Edition. Talk about being slow to catch up...

    Seriously, there is very little (most would say none) incentive to use csh anymore. Even in its tcsh incarnation, it's almost completely been superceded by zsh. You should check it out for your own sanity.

    Should you desire, you can even turn on the god-awful insane history mechanism that all those weird-ass csh users seem to have gotten ingrained with...

  50. 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.

  51. Re:What the author really wants is a POSIX-only Sh by psamuels · · Score: 1
    Obviously what the author wants is a shell which implements just the POSIX standard and nothing else.

    The POSIX shell standard is much closer to ksh than to Bourne shell. If that's what you want, ash is pretty much what you described.

    Problem is, ksh / POSIX sh is not the lowest common denominator - there are old systems out there that still only have Bourne. (Contemplate for a moment, if you will, the design decision of the autoconf author not to rely on the existence of shell functions! Even Bourne shell has had those since the mid-80s or so.) Most vendors don't seem to care about pre-POSIX shells any more, though.

    --
    "How can you claim that you are anti-crack, while still writing a window manager?" — Metacity README
  52. 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 psamuels · · Score: 1
      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.

      Well, bully for you and your Pentium III. I do development work on a PII-400. It's faster than my Pentium-MMX-166, you see. When I have to re-run a 'configure' file, which sometimes occurs every five or ten minutes (depending on what I'm working on, of course), it takes 60 seconds or so. With bash, it takes 65-70 seconds. To me, ash represents a tangible improvement.

      If you think I should just get out of the dark ages already and get that dual Athlon I've been wanting, please reply so we can make arrangements for where and how you can ship it to me.

      --
      "How can you claim that you are anti-crack, while still writing a window manager?" — Metacity README
    2. 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.

    3. 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.

    4. Re:ash beats bash by something like 10% by cburley · · Score: 1
      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.

      [...]lately, every developer seems to be saying this, and it's really starting to add up.

      "Lately"? "Starting"??

      ;-)

      --
      Practice random senselessness and act kind of beautiful.
    5. 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. :-/

  53. Comment removed by account_deleted · · Score: 2, Interesting

    Comment removed based on user account deletion

  54. Re:oh my gosh by Cheese+Metal+Rulez!! · · Score: 1

    Your argument is roughly equivalent to the statement:
    "I think prawns are quite attractive - KILL ALL CREATURES OF THE SEA!!!!!1!!1!!!!!!!!

  55. '...it's too big and too slow' ... by spuk · · Score: 1

    ... but it's always on core ...

    --

    "Video bona proboque; deteriora sequor." -- Ovid
  56. 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.

    1. Re:Linux Standard Base by rasactive · · Score: 1

      >In a nutshell Trying to sneak a pun by? It didn't go unnoticed.

  57. 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 edinho · · Score: 1

      ???

      It seems to work for me with bash 2.05a.

    2. 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.
    3. Re:Example bash bug by jbgreer · · Score: 1

      What version of bash are you using? I suspect that you have generalized a feature of bash that you noticed in a different context. In particular, pipe chains are implemented such that the last expression is executed in a subshell. This has the effect that your variables into which you read values are not directly available outside of the loop. For instance:

      ls | while read foo bar
      do
      echo $foo
      done

      echo $foo

      doesn't work as you probably expect. This is especially unexpected behaviour if you have used AT&T Korn shells, since they do not implement the final command in a subshell. On the otherhand, this is permitted according to the UNIX 1 specification.

      --
      The Norton Anthology of English Literature, 4th Ed., Vol 2
    4. 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.
    5. 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
  58. Re:why not... by The+Pi-Guy · · Score: 1
    Um, because...
    1. Make usually calls /bin/sh -c, returning us to our original problem.
    2. Here's the problem with CSH.
      1. Program gets written with a real CSH. (Or with CSH linked to TCSH.)
      2. End user uses the opposite, which has a different implementation of feature x, or flat-out doesn't have it.
      3. See step 1.
    --j0shua
  59. Ditto this ! by Macka · · Score: 1


    The korn shell is supposed to be 'the' POSIX compliant shell and ships with all commercial unix systems. So if cross platform compatability is required, korn is the logical choice.

    Why would anyone choose to write scripts in sh anyway, it's like writing using a chisel a stone. Ksh at least has 2D arrays, and some pretty decent builting functions for pattern matching.

  60. a non issue? by mrsbrisby · · Score: 1

    a lot of slashdotters have pointed out this is a non-issue; as far as writing scripts goes, so long as you are "careful" you won't run into any problems.

    right? i mean exactly how hard is it, knowing, loving, and using bash to click-off the parts of your programmer mind that deal with the bashism shortcuts you take for granted?

    as a programmer, i frequently need a few steps to shift gears. i'll be working for four or five hours on some C, flip into a perl program and find myself (quite unconsciously) dropping some $char@act%ers*. they're deceptively similar languages in construct, and i must say "okay, now i'm writing perl" or java or bash or forth or whatever.

    this is not to suggest that our friend in need is without hope; that even if he had a real bourne shell he would still make mistakes. this simply illustrates that it's more difficult to avoid those mistakes EVEN WITH the knowledge.

    if you're a non-programmer, don't bother responding to me, because it's hopeless to think you'll understand... just because you can quote the linked faq doesn't mean you actually understand it.

    the case of typing export out is such a silly one that I often make the same error: i have a rather large administration tool that runs on NT, 2000, Solaris, Linux, and OpenBSD. It's goal is to unify their various differences so that administration can remain (roughly) the same.

    as such, it's a myriad of shell scripts, 300-400 line C programs, perl programs, wrappers, and whatnot. the MOST COMMON PROBLEM that I deal with is because I develop initially on a Linux system. Linux is extremely developer friendly (perhaps because it was developed for developers, but that's a hiyku waiting about that i'm not going to release today) - and solaris, NT, and 2000 are not (again, YOU can disagree; I know many hailstorm developers that love the new windows platform. you're still wrong.)

    however. i did mention that there was hope, and to that i will now digress: your application (whatever it is) must SOMEHOW share some commonalities with the platforms in which you wish it to run.

    if your application is a C program: write your installer in C. or better still? write makefiles. perl program? even easier: you have a shell (perl, well, sort of). if your program is a bash script (and i'll pity you if it is) you simply require the use of bash.

    i make my administration tool work on many platforms by making those platforms more similar- that way the jump is shorter.

    i also have the added benefit of being able to test my changes. they go from my development machine to a staging system (one of each flavor) and from there onto the production webs.

    i can't very well suggest that you "avoid making mistakes", and if I suggest "ash" or "zsh" or "csh" i'm simply suggesting that you require something else. i'm not going to have any allusions about it, however: if it doesn't work, use something else ANYTHING else. even if that means you need to slap solaris on a machine (for bourne), or perhaps stealing the *bsd's shell.

    you have more than your two (obvious) options- in extremeties and in directions. remember your goal first, and then find out what problems exist.

    best of luck

  61. Re:bash SUCKS, csh ROCKS! [HA!] by Stormin · · Score: 1

    Must be an Albany graduate. For some reason (at least when I was there), csh was your default shell. If you were lucky you got it changed to tcsh before they disabled ypchsh for "security reasons". Bash? Nobody used it. I remember setting up Linux for the first time back then, trying to figure out how the heck environment variables worked in Bash. I knew this was a goddam simple question, but nobody at school knew because everyone there had only seen C Shells. I also knew that asking a question like "How do I set environment variables in Bash" on the net would not get me the answer. But at the time, a file that said "FOO=bar ; export FOO" or "export FOO=bar" was not that easy to find. I don't know why they continued to use CSH scripts for everything even when it appears everyone else in the world uses bash.

  62. What about the POSIX shell? by pkesel · · Score: 1

    Since HP-UX 11 came out I believe /bin/sh is the POSIX shell. Not really Bourne exactly.

    And I think most of us are bright enough to test our code a bit on those platforms for which we are responsible. Whining about shell discrepancies is a bit lame. What happened to the news?

    --
    - Sig this!
  63. 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

    5. Re:Too much history by taniwha · · Score: 1
      I actually ported the 2.8BSD segmentation overlay loader back to V6



      And I did a V6 port to the vax ..... :-)

  64. Real Bourne Shell will be released as source by juhtolv · · Score: 1

    Real Bourne Shell will be released as source code sooner or later by Caldera. Here is the press release:

    http://news.linuxprogramming.com/news_story.php3?l tsn=2001-08-20-003-06-CD

    http://ir.caldera.com/ReleaseDetail.cfm?ReleaseID= 57417

    And here are some quotes:

    "The Regular Expression library and tools will be made publicly available on SourceForge this week at http://unixtools.sourceforge.net. In coming months, Caldera will Open Source other UNIX tools and utilities, including pkgmk, pkgadd, pkgrm, pkginfo, pkgproto and more, as well as the Bourne shell, lex, yacc, sed, m4 and make. The licenses under which these technologies will be Open Sourced will be decided based on community and business needs."

    So, you must keep you eyes on this:

    http://unixtools.sourceforge.net/

    Meanwhile you can do portable shell-scripting with help from these WWW-pages:

    http://www.raycosoft.com/rayco/support/porting.htm l

    http://www.raycosoft.com/rayco/support/SANS_2001_f iles/v3_document.htm

    http://sources.redhat.com/autobook/

    http://sources.redhat.com/autobook/autobook/autobo ok_208.html

    Ash is really good Bourne Shell clone and POSIX-shell implementation. I really like to use it for my shell-scripting, because it prevents me from using bashisms. In my Debian GNU/Linux 2.2 Potato /bin/sh is actually a symlink to ash that I compiled from sources I took from unstable Debian and it works.

    But if /bin/sh is symlink to bash and you have some bashisms in you script that starts "#!/bin/sh", it seems, that even in that case bash won't complain about those bashisms.

    But you must check out, which version of ash you are running. Debian has always used the latest version of ash. I think it is downloaded from this place:

    ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src /bin/sh/

    Red Hat Linux had ash version 0.2 and it really sucks. Then I made bugreports and latest versions of Red Hat have fresher version of ash.

    But it seems, that Slackware still has that ash version 0.2:

    ncftp ...ware-8.0/source/ap/ash > pwd
    ftp://ftp.slackware.com/pub/mirrors/slackware/slac kware-8.0/source/ap/ash/
    ncftp ...ware-8.0/source/ap/ash > ls
    ash-linux-0.2.diff.gz _ash.tar.gz
    ash-linux-0.2.tar.gz SlackBuild
    ncftp ...ware-8.0/source/ap/ash >

    BTW I really don't understand, why somebody would want to create installer scripts, when this kind of tool exists: http://www.easysw.com/epm/

    EPM Is:

    A free UNIX software/file packaging program that generates distribution archives from a list of files. EPM Can:

    Generate portable script-based distribution packages complete with installation and removal scripts. Generate vendor distributions in AIX, BSD, Compaq Tru64, Debian, HP-UX, IRIX, Red Hat, and Solaris formats. Provide a complete, cross-platform software distribution solution for your applications.
    --
    Juhapekka "naula" Tolvanen - http://iki.fi/juhtolv
  65. THE Standard by Mad+Marlin · · Score: 1
    And what, if I might ask, is the standard?

    The IEEE Standard 1003©2 ¥``POSIX©2'' specification for the shell©

  66. Hmm. How bout... by SnafuX · · Score: 1

    This is somewhat OT but I think it is a valid point. How bout...a better shell to replace sh on those "enterprise" *nixen. I have not quite figured out why the "big guys" have not grown up a bit and started using more robust shells like bash and/or ksh. Frankly, I'm a korn shell guy when it comes to scripting jobs which is what I do for a living (ksh and Perl). Solaris ships with ksh88 out of the box. Solaris 8 might actually come with ksh93 now (NOT including dtksh which is a superset of ksh93 with dt code built-in) but I could be mistaken about that. However, Solaris still bumps into borne if one needs to go into maintenance mode. Now, I am not a hard-core Unix code hacker and I don't proclaim to know everything about Unix, but I have my fair amount of knowledge. No doubt, the first reply to this will be: It can't be done because of compatibility issues. BAH! I really do not think it would be that difficult to build and use the more up-to-date shells into the vanilla installs for those enterprise type *nixen. Why would you change? I know bash finally added support for arrays not too long ago (a couple years now?). Korn does arrays, but borne, does not. Can borne do tertiary conditions? I don't know, never tried but I doubt it. Does borne allow all of the test switches that bash and korn can do? The ever-loved command-line recall is a good 'nuff reason to do away with borne. Borne is old and it's deprecated. Everything has to evolve sometime. I'm not leaving out csh and tcsh on accident. I just am not a cshell kind of guy but I know it is very powerful. FreeBSD uses it as the default root shell in a vanilla installation. I believe even FreeBSD falls back to borne in maintenance mode. I think, in the end, the biggest reason why those Unix companies don't "upgrade" to the more robust shells is compatibility. Perhaps the second biggest reason is, "why? It works!". I agree, it works and if that were the only reason, I admit, that is a worthy reason. However, I feel its time to move on!! Things don't get better if they remain in the old ages.

    --
    - J
  67. Re:bash SUCKS, csh ROCKS! [HA!] by psamuels · · Score: 1
    even Tom "csh Considered Harmful" Christiansen uses tcsh interactivly. Just don't use it for scripting.

    Well, at least he did, back in the day when bash had not really matured and gained market share and no other shell had the useability features tcsh had (tab completion, up/down arrow editing, etc). I wouldn't bet any money that he still does (although I wouldn't bet against it either - who knows, he might).

    But bash now has almost all the features people (including me!) liked so much about tcsh, and zsh of course has all those and much much more. So there's no good reason anymore not to switch - well, there are reasons (availability on all machines that you use, availability of people to help you who are knowledgeable in bash/zsh, difficulty of the transition, etc) but the days of tcsh being "easiest to use" are long gone.

    Besides, we can't all be the great tchrist - I imagine he has no trouble keeping syntaxes of esoteric features of different shells in his head and not confusing them, but I find it much easier to use the same shell syntax interactively as I use for scripting. That's the biggest reason I switched to bash, lo these many years ago. (Since then I've found many other reasons not to regret the migration.)

    --
    "How can you claim that you are anti-crack, while still writing a window manager?" — Metacity README
  68. 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.

  69. 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
  70. 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.

  71. ash and Debian by bkhl · · Score: 1

    Nowadays, if you install the ash Debian package, it asks you if you want to use it for /bin/sh.

  72. More Details, Please by Anonymous Coward · · Score: 1, Insightful
    This has caused inconsistencies (mostly bugs in bash) when writing a generic UNIX sh script that works fine on commerical *NIX's."

    What exactly were the "inconsistencies"? How many were there? What features did they involve? I've been in the business long enough to recognize situations where my own unfamiliarity with a particular technology spanks me hard. Perhaps the original poster is finding him/herself in a similarly humbling situation?

  73. 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.

  74. Even the original Bourne Shell won't help you. by jschrod · · Score: 1

    The only way to test if your scripts will work on different Unices is: Test them on different Unices. You have only Linux? Too bad, if you really earn your money with that work, buy some other machines. That's professional life, deal with it.

    The situation has been spelled out best by Larry Wall in an old Usenet posting:

    Drew Mills writes:
    : A contest to see who could write the most useful script that could
    : actually be used in the most languages *as is* [...]

    I've written some scripts that work in 582 different languages,
    all of them named sh.

    Since, your problem is: There ain't no such thing as a standard Bourne shell. The real original Bourne shell was a beast - believe me, I've had access to the source. The C code was turned to some pseudo-Algol by way of macros (e.g., #define THEN ) { etc.) Most Unix vendors replaced it by an own implementation sooner or later.

    --

    Joachim

    People don't write Manifestos any more -- what's going on in this world? [Frank Zappa]

  75. 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.

  76. Oh, Great by Prong · · Score: 1

    Does this sound familar:

    "Why isn't $NEW_SW available?"

    "Because the install script crapped all over itself, and I'm trying to figure out what it's doing."

    "Didn't you call support?"

    "Yeah, but apparently our latest set of OS patches is not something they tested with."

    "Did you get an ETA on the fix?"

    "A couple of weeks, maybe more."

    "But we need it now!"

    "I know. That's why I've been here the last two days going over 120k of poorly written, documented and tested install script!"

    Any vendor shipping an install that requires more than a few lines of /bin/sh gets a defect call from me. There is no reason on earth not to ship and use more robust tools if your install truely is that complicated.

  77. Re:Which Linux packaging system? Obviously... by Jorrit · · Score: 1

    Ugh. I do NOT want to target a package to some linux distribution. I want to target a package to linux in general. I don't want to care about all those distribution. My package will most likely work on all of them (hopefully).

    So this means that I cannot simply do what you want and take the 'linux packaging solution' because linux does not have a standard packaging solution. All distributions have some but not linux itself. But the packaging systems from the distributions are useless as I don't want to target a distribution.

    Greetings,

    --
    Project Manager of Crystal Space (http://www.crystalspace3d.org). Support CS at http://tinyurl.com/cb3x4
  78. Re:pdksh by bwulf · · Score: 1

    > Last I checked, OpenBSD was using pdksh

    Yeah, it appears so. Ash is /bin/sh in 4.4BSD-Lite, FreeBSD and NetBSD.

    OpenBSD removed Ash around four years ago, according to their CVS.

  79. +1 Supportive on the MQR standard by MarkusQ · · Score: 1
    Crag --

    Sorry you got modded down for being right. If I had real points I give you one, but at present the only mod points I have are the these fake ones I mint for my own private mod system.

    -- MarkusQ

  80. 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?
  81. 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?
  82. 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.

  83. zsh has an sh compatibility mode by donio · · Score: 1

    From the zsh manual:

    "Zsh tries to emulate `sh' or `ksh' when it is invoked as `sh' or `ksh' respectively."

    I don't know how strict the sh emulation mode is.

    1. Re:zsh has an sh compatibility mode by Mistah+Blue · · Score: 1

      That is fine. However, the issue is with installer code. The software company has no control over whether the user has zsh installed. They must depend on the default shell (that being bash) is present.

      I would echo what has already been said, and do not use bash esoterics. Stick to the least common denominator between sh and bash.

  84. I use ash by drj11 · · Score: 1

    I use ash, because it is /bin/sh on FreeBSD which is what I use mostly. I believe it is fairly conservative (that is, doesn't implement much more than a minimal bourne shell). I know the POSIX spec' fairly well. I never have any problems writing incompatible scripts (by, for example, accidentally using features that some other shell doesn't implement). I very occasionally find myself thinking that the bash/POSIX ksh syntax for arithmetic expressions would be nice (usually around the same time that I think I ought to rewrite the script in awk/python/c).

    Of course, because I mostly only use FreeBSD I don't get to test my scripts on other shells very often... (HP-UX, OSF, and Ultrix used to be good platforms for finding quirky shells).

    The shell I use most often is rc (from plan 9), but I don't do "real" programming in that because no other system has it installed (certainly not by default). Having a fairly even mixture of programming sh and programming rc is a good way to mess up your mind.

    This comment has been scanned for viruses.

  85. Running on other operating systems by bjb · · Score: 1

    The only problem I ever ran into was that a lot of people seem to shebang #!/bin/sh on Linux systems, when in fact they're using Bash symantics. This confuses scripts trying to run on systems with a real bourne shell (e.g. Solaris). I don't mind that Linux doesn't have a proper Bourne shell, I just wish coders would properly acknowledge #!/bin/bash.

    --
    Never hit your grandmother with a shovel, for it leaves a bad impression on her mind...
  86. Easy by strombrg · · Score: 1


    I've written quite a bit of /bin/sh code, and have found it easy to stick to a portable common subset of bourne shell and bash. Just stay away from the truly esoteric stuff, and you're fine.

  87. Do not log in as root by Lazaru5 · · Score: 1

    You either misunderstand or misremembered the explanation. No scripts break when root's shell is changed.

    You shouldn't change root's shell because you shouldn't be using the root acount often enough for it to matter. If you use su to become root, use the -m flag so it keeps your existing shell and environment. That's what it's there for. Or, install sudo and use 'sudo bash' to become root. On all my servers I haven't 'logged in' as root in at least 6 months. Linux users use the root account far too often and then carry their bad habit to other OSes when they switch.

    The other danger is not being able to use dynamically compiled shells in single user mode. You mentioned this.

    --

    --
    My comments and opinions completely reflect those of anyone and anything I am remotely associated with.
  88. Re:Not "sh" for Linux... by t · · Score: 1

    Have you ever actually read the GPL?

  89. 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''.

  90. Which packaging system by Recluse · · Score: 1

    A linux packaging system, eh? This is make, make install? Or do you mean something like rpm? Or deb?

    --
    Look ma, I'm a .sig
  91. Get the right book by ghengismcbangus · · Score: 1

    Hi:

    I do exactly the same thing - one shell script has to install my company's product on Linux, Solaris, AIX, and HP-UX. I develop the scripts on Linux, and I've been bitten in the ass by accidentally using a Bash-only extension. I have found this book to be very helpful:

    Blinn, Bruce, _Portable Shell Programming_
    ISBN 0-13-451494-7

    -Ghengis

  92. Re:The solution is... by aminorex · · Score: 1

    Okay, I may be deviant here, but I don't think
    swearing at a troll in an effort to get a message
    through his stone head is in itself a troll.

    --
    -I like my women like I like my tea: green-
  93. 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