SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541
Rep:
Quote:
Originally Posted by genss
y, arrays are a bash thing
Only in the interests of providing a little information... From at least 1989 KornShell has provided arrays.
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.
Pg. 61 Arrays
Pg. 129 Arithmetic Expressions
Pg. 170 Arrays
Strangely, the BASH assignments and manipulation of arrays look, well, pretty much identical to KSH.
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" :-)
Which is a no-op on the Slackware default install, but should make things more robust, because it removes an implicit assumption (sh = bash) and the reliance on a symlink. If you ask me, I'm not against your proposal.
Yes, but... Making that change now could break some shell scripts (be they included in Slackware or written by users), as then bash's behavior, not being called as sh any more, could change. I'm still a beginner in shell scripting, especially in bashing (?!) so I can't give examples, but I assume that our BDFL is not ready to take that risk.
Only in the interests of providing a little information... From at least 1989 KornShell has provided arrays.
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.
Pg. 61 Arrays
Pg. 129 Arithmetic Expressions
Pg. 170 Arrays
Strangely, the BASH assignments and manipulation of arrays look, well, pretty much identical to KSH.
interesting, thx
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
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541
Rep:
Quote:
Originally Posted by bimboleum
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 ...
As a fellow old fart...
Quote:
Originally Posted by bimboleum
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.
Yup, shebang every shell program (lordy, I hate the word "script" for a shell program).
Quote:
Originally Posted by bimboleum
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!).
Actually, the name you log in with does not matter once past the log in sequence; all that matters is the UID (and GID, too). If you have a separate account such as kroot with a UID and GID of zero, well, that's root by any other name.
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! 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.
The change of the Shebang of rc.S would break other shell scripts? How? Please explain.
Already quoted from bash's man page by Stuart:
Code:
If bash is invoked with the name sh, it tries to mimic the startup
behavior of historical versions of sh as closely as possible, while
conforming to the POSIX standard as well.
I don't know exactly how bash's behavior differs upon the name with which it is invoked, but am assuming that theses difference could result in a script also behaving differently -- possibly not the way it was intended to. Reading you response I realize that I probably should have stated this remark as a question.
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.
Last edited by Didier Spaier; 06-09-2014 at 02:15 PM.
Reason: PS added.
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.
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.
Did you post in the right thread? I ask because the link between you statement and the topic escapes me.
...Of course changing the shebang of only rc.S won't change the behavior of another script.
I don't think it'd change the behaviour of rc.S either. I've changed many scripts over the years from #!/bin/sh to #!/bin/bash on Linux (where sh is symlinked to bash) and they all continued to work as they did previously.
I don't think it'd change the behaviour of rc.S either. I've changed many scripts over the years from #!/bin/sh to #!/bin/bash on Linux (where sh is symlinked to bash) and they all continued to work as they did previously.
that's interesting. i too changed the shebang of rc.S to /bin/bash and my system now boots with /bin/sh linked to /bin/mksh. can you name some other scripts which are affected?
that's interesting. i too changed the shebang of rc.S to /bin/bash and my system now boots with /bin/sh linked to /bin/mksh. can you name some other scripts which are affected?
That's the function of the shebang, in this case it calls /bin/bash to execute the code so where /bin/sh links doesn't care anymore.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.