A Real Bourne Shell for Linux? 388
"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?
Easy. (Score:5, Informative)
Re:Easy. (Score:2, Informative)
Also, recent FreeBSD 4.x releases have replaced 4.4BSD csh with tcsh (original csh being available as a port).
Re:Easy. (Score:2, Interesting)
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
I still prefer bash, despite FreeBSD's objections
Re:Easy. (Score:2)
Re:Easy. (Score:2)
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/bash (Score:3)
Re:/bin/bash - It all sounds so brutal (Score:3, Funny)
Re:/bin/bash (Score:2)
And yes, I have been burned regularly by scripts which assumed that "sh" would have bash extensions.
Re:No other OS? (Score:3, Interesting)
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.
Re:No other OS? (Score:3, Funny)
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.
From Moon Zappa straight to William Shatner: GET. A. LIFE.
Re:No other OS? (Score:2)
Er, not heard of Jumpstart, have you?
Try this out! (Score:1, Informative)
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)
Re:Try this out! (Score:2, Insightful)
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.
It's a non-issue. (Score:5, Interesting)
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.
Re:It's a non-issue. (Score:2, Insightful)
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.
Re:It's a non-issue. (Score:2)
Re:It's a non-issue. (Score:5, Informative)
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 ->
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
Re:It's a non-issue. (Score:2)
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
Re:It's a non-issue. (Score:2, Informative)
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
Re:It's a non-issue. (Score:2)
Re:It's a non-issue. (Score:2)
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
Re:It's a non-issue. (Score:5, Insightful)
Re:It's a non-issue. (Score:2)
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
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.
Re:It's a non-issue. (Score:2)
Re:It's a non-issue. (Score:2)
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
ash beats bash by something like 10% (Score:2)
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.
Re:ash beats bash by something like 10% (Score:2)
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.
Embedded systems more important than you think (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?
Re:ash beats bash by something like 10% (Score:2)
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.
Re:ash beats bash by something like 10% (Score:2)
Re:It's a non-issue. (Score:2)
This is why ksh is called "ksh", not "sh".
Re:It's a non-issue. (Score:2)
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.
Re:It's a non-issue. (Score:2)
7 Nov 2001 (updated 7 Nov 2001)
Slackware uses ash for toolset (Score:5, Informative)
Basically, Slackware uses ash for development for the exact reasons you're looking for a Bourne-compatible shell.
Have fun.
Too much history (Score:2)
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
Re:Too much history (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?
Re:Too much history (Score:2)
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...)
Re:Too much history (Score:2, Informative)
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
Re:Too much history (Score:2)
Bruce
Re:Slackware uses ash for toolset (Score:2)
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. ;)
bash as /bin/sh (Score:4, Informative)
You haven't seen Polished Linux Distribution [pld.org.pl]. PLD's
(Plus, PLD is fully IPV6 ready
Re:bash as /bin/sh (Score:2)
odpierdol siê
What does that mean anyway? I'm always on the lookout for new ways to be profane.
Re:bash as /bin/sh (Score:2)
look at their web page.
from the pictures, it is quite clearly penis linux distribution
Bourne shell or POSIX shell? (Score:5, Informative)
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.
Re:Bourne shell or POSIX shell? (Score:2)
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.
Ash (Score:3, Interesting)
Ever try ash [debian.org]? Here's a size comparison just to intrigue you a bit.
Re: (Score:2, Interesting)
As to distro startup scripts... (Score:3, Informative)
I couldn't say for other distros, but Debian policy [debian.org] 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.
ksh: I built a ksh93 rpm (Score:1)
For information on Korn shell, see http://www.kornshell.com/ [kornshell.com]
With ksh, you can more easily interoperate with commercial UNIX systems, which now a days all come with ksh.
What's the problem? (Score:1)
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
ash (for debian, at least) doesn't work (Score:2)
not quite right (Score:2)
Re:not not quite right (Score:2)
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.
And which "real Bourne shell" would that be? (Score:4, Insightful)
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.
Re:And which "real Bourne shell" would that be? (Score:2)
If you want to deliver on Linux, please use the Linux packaging system.
What is the Linux packaging system?
Which Linux packaging system? Obviously... (Score:2)
Re:And which "real Bourne shell" would that be? (Score:2, Interesting)
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.)
Re:And which "real Bourne shell" would that be? (Score:2)
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.
Re:And which "real Bourne shell" would that be? (Score:2)
In any case, programs like my EPM (see http://www.easysw.com/epm/ [easysw.com] 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...
Re:And which "real Bourne shell" would that be? (Score:2)
Which direction are you worried about? (Score:5, Interesting)
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
* 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
Re:Which direction are you worried about? (Score:2)
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
What the author really wants is a POSIX-only Shell (Score:2)
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.
Portable Shell Programming (Score:2, Informative)
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 [amazon.com] is a good resource that might help as well as GNU Autotools documentation [huji.ac.il], 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 [raycosoft.com]
Linux Standard Base (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 [linuxbase.org] 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.
Example bash bug (Score:3, Interesting)
The following works in UNIX sh, but not in bash:
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.
Re:Example bash bug (Score:2, Interesting)
Re:Example bash bug (Score:2)
Re:Example bash bug (Score:2)
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.
Why stay in the past? (Score:2)
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.
Re:Why stay in the past? (Score:2)
So does ksh.
If you mean inline editing, more generally, so does ksh, using both Emacs and vi keybindings if you wish.
Yep, so does ksh.
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.
Check for bash during configure (Score:2, Interesting)
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.
Solution for Debian users (Score:2)
This actually works pretty well, and it's great for finding broken sh scripts.
You are clueless, there is a POSIX standard! (Score:2)
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 [unix-systems.org] online.
Search for ``shell command language''.
Re:Not "sh" for Linux... (Score:1)
(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!)
Re:Not "sh" for Linux... (Score:2)
On the other hand, sometimes you just don't care, and you can make full use of bash or ksh or whatever.
Re:Not "sh" for Linux... (Score:2, Informative)
Granted, not really Linux-related answer, however it does answer the question. Also, note last para of the question -- this is not about interactivityportability.
Re:Not "sh" for Linux... (Score:2)
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.
Shared-copy-on-write is PATENTED (Score:2)
Have you ever heard of shared-copy-on-write executables?
Have you heard of U.S. Patent 4,742,450 [mit.edu] on the shared-copy-on-write memory segments that loading such executables requires?
Did you even read the complaint? (Score:4, Interesting)
Ask Slashdot becomes less helpful by the nanosecond.
- A.P.
Re:Did you even read the complaint? (Score:4, Insightful)
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
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
...
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.
Re:Did you even read the complaint? (Score:2)
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
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.
Re:Did you even read the complaint? (Score:2, Insightful)
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.)
Re:Did you even read the complaint? (Score:2)
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
Re:Did you even read the complaint? (Score:2)
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.
Re:Did you even read the complaint? (Score:2)
Question exchange? (OT) (Score:2)
I even submitted a story about it, but it was rejected:
Re:What vacuum are you living in? (ksh and zsh) (Score:1)
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.
(Sorry, a little clarification) (Score:3, Insightful)
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
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...
Re: (Sorry, a little clarification) (Score:4, Insightful)
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.
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.
Re:2nd hit on Google (Score:2)
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
Re:2nd hit on Google (Score:1)
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
Re:2nd hit on Google (Score:2, Informative)
Here is the source to what is very close to "the real thing"
ftp://ftp.freebsd.org/pub/FreeBSD/branches/4.0-
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?
Re:Debian uses ash. (Score:2)
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.
That's like Jumbo Shrimp (Score:2)
Simple bash -- A phrase I'd never expect to hear!
On my system:
131072 sh
688128 bash
Re:bash SUCKS, csh ROCKS! (Score:2, Informative)
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 [perl.com] 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.
Re:bash SUCKS, csh ROCKS! (Score:2)
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.
Re:bash SUCKS, csh ROCKS! (Score:2, Informative)
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
Re:bash SUCKS, csh ROCKS! (Score:2)
Re:a real bourne shell (Score:2)