Quote:
Morris L. Bolsky, David G. Kornm, The KornShell Command and Programming Language (Englewood Cliffs, NJ: Prentice Hall, 1989, IDBN 0-13-516972-0), Copyright 1989 AT&T Bell Laboratories.
|
sh, bash, ksh and other contraversies
Hi,
I have been around for more years than I care to think about so my opinions may not be worth much ... ravings of an old fart ... BUT:- I think it is good practice (when considering shell scripts) that the shebang line reflects the nature of the script so if it uses so-called "bashisms" then use #!/bin/bash, even though you may consider it unnecessary because sh is linked to bash. For those who indulge in AIX, you will notice that although it uses the Korn shell for it's init scripts, /bin/ksh is the old pre-93 ksh (the ksh that shipped with the original AIX) and post-93 ksh is included as ksh93 ... I hope this is accurate .. it has been a while since I used an AIX system. I use ksh as my login shell .. have done this from 1989 onward .. and in order to use ksh when I su to "root", I have a specific username (kroot) which is uid 0 with /bin/ksh as it's login shell. This leaves username "root" as whatever is the specified on the system I am using, specifically so that init scripts run as designed (not just as coded!). What are these ravings all about, you may ask ... well, getting all hot and bothered over which shell does what and how much is not worth it ... they all have their advantages and disadvantages so "horses for courses". On the other hand, don't get me started on "csh" :-) As always, YMMV cheers pete pete hilton saruman@ruvolo-hilton.org |
Quote:
|
Quote:
my experience is from replacing bash with ash, for fun guess assuming arrays are bash specific was false oh well, you learn something every day |
Quote:
Quote:
Quote:
The shell specified in /etc/passwd is the shell program you get when you work on the console or open a terminal, be that sh, bash, ksh, whatever else tickles your fancy. If you're executing programs as UID 0, you're going to be the god of the machine; if you execute them as you, well, you're going to be you (and won't be able to cause much damage, eh?). Place I worked for, oh, about 12 years (a Sun farm) insisted that all users had to use C-Shell (which was written at Berkeley (IIRC) when all of 'em were dropping acid and smoking weed: how else would they have come up with that mess! :rolleyes: Because I was the only non IT guy with a Sun work station, I ran my own stuff my own way (and insisted that my log in shell be KSH on every other system). Of course non of the shell programs were written in C-Shell (thankfully), we wrote all of 'em in Bourne or Korn and things worked (and are still working I've been told) just fine, thank you very much (been retired about five years). My complaint with BASH is simple: it violates the founding principles of Unix (and, thus, Linux) as postulated by Doug McIlory (see below for that). Bourne and Korn have not changed over the years (well, Korn a tiny little bit from '89 to '93 plus a twiddle here or there, Boune not at all since like forever). BASH? They keep screwing with it, adding more and more and still more "functionality" and bells and whistles, right down the rosy path to incompatible older shell programs and broken systems. I suppose it is a good feature to have BASH behave itself with the #!/bin/sh; be an awful mess if it didn't. You know that psychology thing? Glass half full or empty? Engineer: neither; the glass is too big (to do what it needs to do). I still write pretty much everything in C. I learned C++ (and learned, right quick, that I didn't really care for it all that much and don't really ever use it unless forced to). I will continue to write shell programs in KornShell simply because I have not found anything else worth a damn. I do so love being an old fart. |
Quote:
|
Quote:
Code:
If bash is invoked with the name sh, it tries to mimic the startup PS Re-reading your response I see that I didn't answer your question. In fact I was thinking of the consequences of deleting the symlink and changing the shebang if need be for *all* scripts. My bad excuse being that English is a second language for me ;) Of course changing the shebang of only rc.S won't change the behavior of another script. |
Actually, Bash follows the UNIX philosophy. While it's functionality has expanded to incorporate syntax and subroutines of other shells to be more comprehensive, it is still a shell and only still a shell.
|
deleted.
|
Quote:
|
Quote:
|
Quote:
|
Quote:
|
Quote:
For the same reason the default shell the installer chooses for user root (in /etc/passwd) is not necessary what the system uses for booting. In any case the shebang tells you the interpreter used. OpenBSD uses its own version of ksh. FreeBSD uses csh for user root but the rc scripts call /bin/sh. I don't know how POSIX are the init scripts on both systems. Personally I'd avoid bashism in Linux init scripts as much as possible. Perhaps I'm telling you what you already know. TEXT ADDED: OK, now I realize what you meant. You mentioned your system boot changing rc.S shebang to /bin/bash to check if other scripts could contain bashism. Sorry for the noise. :) |
All times are GMT -5. The time now is 11:04 AM. |