LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 06-07-2014, 08:57 PM   #31
ReaperX7
LQ Guru
 
Registered: Jul 2011
Location: California
Distribution: Slackware64-15.0 Multilib
Posts: 6,558
Blog Entries: 15

Rep: Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097

I think FreeBSD uses csh.
 
Old 06-08-2014, 02:18 AM   #32
dederon
Member
 
Registered: Oct 2013
Posts: 107

Original Poster
Rep: Reputation: 56
This is annoying. I've should have chosen another title (like "wrong /bin/sh shebang line in /etc/rc.d/rc.S" or so).

All I wanted to say was:

1. There is Bash code in /etc/rc.d/rc.S.
2. This file has a "/bin/sh" shebang line, which is wrong.
3. The fix is easy - change /bin/sh to /bin/bash.

i am serious about this matter, as rc.S is one of the most importants scripts. I'd really like to read an oppinion from Pat about that, but I think he won't wade through all the "ksh vs. bash" pages.
 
3 members found this post helpful.
Old 06-08-2014, 02:31 AM   #33
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,056

Rep: Reputation: Disabled
Quote:
Originally Posted by dederon View Post
1. There is Bash code in /etc/rc.d/rc.S.
2. This file has a "/bin/sh" shebang line, which is wrong.
3. The fix is easy - change /bin/sh to /bin/bash.
Code:
~$ ls -l /bin/sh
lrwxrwxrwx 1 root root 4 déc.  23  2012 /bin/sh -> bash
~$
Isn't that enough?
 
Old 06-08-2014, 05:00 AM   #34
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557

Rep: Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761
Quote:
Originally Posted by dederon View Post
This is annoying. I've should have chosen another title (like "wrong /bin/sh shebang line in /etc/rc.d/rc.S" or so).

All I wanted to say was:

1. There is Bash code in /etc/rc.d/rc.S.
2. This file has a "/bin/sh" shebang line, which is wrong.
3. The fix is easy - change /bin/sh to /bin/bash.
Sure /etc/rc.d/rc.S should really say /bin/sh but really, in the grand scheme of things it just doesn't matter and if it ain't broke, don't fix it.
 
1 members found this post helpful.
Old 06-08-2014, 06:24 AM   #35
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
Quote:
Originally Posted by jpollard View Post
Why would you switch to the korn shell?
Well, I've been using KornShell for..., um, just about 25 years (in Unix, Solaris and Slackware) with zero problems. During that time, BASH came along, tried it, didn't much like it and it kept "improving" (read: bloat). Too, BASH incorporates a great deal of the functionality (and syntax) of both KornShell and Bourne (along with the C-Shell thrown in for good measure).

User accounts on my systems (and those that I've administered over time) have defaulted to /bin/ksh (users are free to change to BASH if they want, most haven't). Haven't had too many complaints.

Leaving system software (including all start up, shut down, rc's alone) to execute as /bin/sh (which, yeah, is BASH, not actual sh) is no problem; things work if you let them.

There is no reason to remove BASH, leave it there, just don't use it -- just change the account shell in /etc/passwd from /bin/bash to /bin/ksh and life is good. Wouldn't mess with the system accounts (except root which is /bin/ksh on all my systems).

I would note that the above has never resulted in any difficulties whatsoever.

Hope this helps some.
 
Old 06-08-2014, 06:59 AM   #36
drmozes
Slackware Contributor
 
Registered: Apr 2008
Distribution: Slackware
Posts: 1,539

Rep: Reputation: 1309Reputation: 1309Reputation: 1309Reputation: 1309Reputation: 1309Reputation: 1309Reputation: 1309Reputation: 1309Reputation: 1309Reputation: 1309
Quote:
Originally Posted by dederon View Post
This is annoying. I've should have chosen another title (like "wrong /bin/sh shebang line in /etc/rc.d/rc.S" or so).

All I wanted to say was:

1. There is Bash code in /etc/rc.d/rc.S.
2. This file has a "/bin/sh" shebang line, which is wrong.
3. The fix is easy - change /bin/sh to /bin/bash.

i am serious about this matter, as rc.S is one of the most importants scripts. I'd really like to read an oppinion from Pat about that, but I think he won't wade through all the "ksh vs. bash" pages.
Bash is designed to be invoked as 'sh' - check the man page:
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.
There are certain pieces of functionality in bash which only work if you switch off POSIX compliance (set +o posix).
Perhaps bash *shouldn't* execute the code you're referring to if it's mimicking the behavior of 'sh' - maybe you should check with the authors of bash?
 
Old 06-08-2014, 07:57 AM   #37
Gerard Lally
Senior Member
 
Registered: Sep 2009
Location: Leinster, IE
Distribution: Slackware, NetBSD
Posts: 2,177

Rep: Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761
Quote:
Originally Posted by 55020 View Post
Hey! Calm down!

It can hardly be news to you that loose statements in a book written in 1993 don't really grok Linux, which first saw the light of day in... 1991. The O'Reilly book is not ksh.
Once again, two wildly inaccurate statements. The second edition was heavily revised and appeared in 2002, 11 years after Linux appeared and 2 years after ksh93 was released as open-source in 2000.

I'm not sure what you mean when you say the O'Reilly book is not ksh. I'm half-way through the book and it certainly seems to be all about the official Korn shell, ksh93, to me.

Quote:
FYI I personally consider ksh to be vastly superior to bash in many regards, and that it's highly regrettable that AT&T killed any hope of wide adoption by hanging onto a restrictive licence until long after bash became impossible to dislodge, but hey, apparently I'm an uninformed elitist, so what would I know.
This is a very strange thread. If you ignore the obvious trolls this Slackware forum is invariably informative, with interesting input from people who have years of experience. But in this thread we've had more than a couple of long-established members offering completely ill-informed opinions, if not indeed outright falsehoods. As if that wasn't bad enough, they have sought to impose certain viewpoints on other users, adopting a contemptuous and dismissive tone in the process that I for one have come to expect elsewhere in the Linux world, but not here. A sad day indeed if that elitist, patronising and ill-informed attitude takes root here.
 
Old 06-08-2014, 08:17 AM   #38
genss
Member
 
Registered: Nov 2013
Posts: 741

Rep: Reputation: Disabled
Quote:
Originally Posted by dederon View Post
eval LUKSARRAY=( $line )

This line, and the following lines

LUKS="${LUKSARRAY[0]}"
DEV="${LUKSARRAY[1]}"
PASS="${LUKSARRAY[2]}"
OPTS="${LUKSARRAY[3]}"

look like bash code to me. Affected is X86_64 current and i686 14.1.

I am not an shell expert, can someone confirm this? Or provide a simple solution? Otherwise I will sot down and write a patch to solve this issue.

heiko
y, arrays are a bash thing

if i read it right something like http://stackoverflow.com/questions/5...tring-variable and a counter
there is maybe a better solution but none comes to mind

there is more bashism in inet scripts and more
also shutdown scripts use "kill" that is the gnu /bin/kill in bash but builtin in ksh so you'd need to change that to /bin/kill or change the flags to be posix so ksh don't fail
 
Old 06-08-2014, 08:38 AM   #39
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,371

Rep: Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748Reputation: 2748
There is also the issue of future proofing. If smash (the new Super Mega All-in-one shell) came along, then a simple change 'ln -s /bin/smash /bin/sh' would allow the init scripts to continue to function.
 
Old 06-08-2014, 09:13 AM   #40
55020
Senior Member
 
Registered: Sep 2009
Location: Yorks. W.R. 167397
Distribution: Slackware
Posts: 1,307
Blog Entries: 4

Rep: Reputation: Disabled
Quote:
Originally Posted by gezley View Post
Once again, two wildly inaccurate statements. The second edition was heavily revised and appeared in 2002, 11 years after Linux appeared and 2 years after ksh93 was released as open-source in 2000.
The CPL is more restrictive than, and incompatible with, the GPL. I didn't say the licence wasn't open source; I said it was restrictive. Even the CPL's progenitor (IBM) has disowned it.

The book's statement that misled you, and at least one more like it, should clearly have been excised from the 2002 revision. They were not. That's what confused you. Please don't keep shooting the messenger; it hurts, actually.

Quote:
Originally Posted by gezley View Post
I'm not sure what you mean when you say the O'Reilly book is not ksh.
You've never seen that Magritte painting? The O'Reilly book is not ksh; the O'Reilly book is a book about ksh.

When I criticise one statement in the O'Reilly book, I am not criticising ksh, nor am I trashing the whole of the O'Reilly book, nor am I trashing *you* *personally*.

Quote:
Originally Posted by gezley View Post
This is a very strange thread. If you ignore the obvious trolls this Slackware forum is invariably informative, with interesting input from people who have years of experience. But in this thread we've had more than a couple of long-established members offering completely ill-informed opinions, if not indeed outright falsehoods. As if that wasn't bad enough, they have sought to impose certain viewpoints on other users, adopting a contemptuous and dismissive tone in the process that I for one have come to expect elsewhere in the Linux world, but not here. A sad day indeed if that elitist, patronising and ill-informed attitude takes root here.
Wow. Just *wow*. Where did all that come from? <spock> Fascinating </spock>
 
Old 06-08-2014, 10:05 AM   #41
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018
Quote:
Originally Posted by drmozes View Post
Bash is designed to be invoked as 'sh' - check the man page:
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.
And it's broken. When bash is started as 'sh' it enters POSIX mode, and runs /etc/profile followed by $ENV as a proper POSIX shell should do; both ksh and ash do this.

But try this: create yourself a test user with /bin/sh specified as its login shell. When you login from the login prompt on a console, everything works as expected, bash starts in POSIXLY_CORRECT mode and runs the POSIX startup scripts.

Now, try a "su - testuser" instead: bash will start in its normal native mode, not POSIX mode. The reason for this, is that bash looks at argv[0] to see whether it is running as 'sh' or not, but when started by 'su' argv[0] is 'su' and bash has no way of knowing what mode to start in. Its approach is fundamentally flawed.

This is why I was saying above that I have no problem with bash when it's run in its native bash mode, but its not a good choice to use for the POSIX /bin/sh.

So, we have the strange situation on Slackware where a user wanting a POSIX shell can't use /bin/sh as their default shell because it wont work correctly.

I accept that this is only a edge-case that the typical user will remain blissfully ignorant of, but stuff like this gets under my skin.

Last edited by GazL; 06-08-2014 at 10:09 AM.
 
Old 06-08-2014, 10:14 AM   #42
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,056

Rep: Reputation: Disabled
Quote:
Originally Posted by GazL View Post
So, we have the strange situation on Slackware where a user wanting a POSIX shell can't use /bin/sh as their default shell because it wont work correctly.
The user can just set /bin/ash as default shell then.

But in the other hand if the user doesn't know that invoked as sh bash behaves as a POSIX shell he or she we will invoke it with the --posix option anyway (just kidding
 
Old 06-08-2014, 12:56 PM   #43
drmozes
Slackware Contributor
 
Registered: Apr 2008
Distribution: Slackware
Posts: 1,539

Rep: Reputation: 1309Reputation: 1309Reputation: 1309Reputation: 1309Reputation: 1309Reputation: 1309Reputation: 1309Reputation: 1309Reputation: 1309Reputation: 1309
Quote:
Originally Posted by Didier Spaier View Post
The user can just set /bin/ash as default shell then.

But in the other hand if the user doesn't know that invoked as sh bash behaves as a POSIX shell he or she we will invoke it with the --posix option anyway (just kidding
Most of my scripts begin with #!/bin/sh as a habit from using Solaris at University, but my scripts have for many years tended to use some bash-specific code (some of which requires set +o posix). I'd have moved to invoking 'bash' if it'd have been required.

My personal opinion of the standard 'sh' is that if you ever had the misfortune to have it as your shell on Solaris, one of the first things you did was to find a binary package of 'bash' and compile or install it :-)
I recall one of the first things I had to do with 'sh' was: stty erase <press backspace>
I did like Solaris though.
 
Old 06-08-2014, 03:37 PM   #44
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018
Ahh yes, the old backspace/del issue. Used to have to muck about with that on AIX too. But that's more to do with the terminal and tty layer than the shell. It's only because bash uses readline for its command line input that you don't see the problem in bash, but have the wrong terminal setting and you can still see the escape codes appear in stdin when you hit backspace when running programs that read directly from stdin without readline, even when started under bash.

Code:
gazl@ws1:~$ od -tx1c
I'm gonna press backspace now. ^H
0000000  49  27  6d  20  67  6f  6e  6e  61  20  70  72  65  73  73  20
          I   '   m       g   o   n   n   a       p   r   e   s   s    
0000020  62  61  63  6b  73  70  61  63  65  20  6e  6f  77  2e  20  08
          b   a   c   k   s   p   a   c   e       n   o   w   .      \b
0000040  0a
         \n
0000041
If anything bash is masking the fact that your terminal isn't set up correctly.

"stty erase ^H" can still be used to fix that, but if you get the right settings in your terminal it's not necessary.
I use these Xresources for xterm:
?.vt100.metaSendsEscape: true
?.vt100.backarrowKey: false

Last edited by GazL; 06-08-2014 at 03:52 PM.
 
Old 06-09-2014, 09:22 AM   #45
jtsn
Member
 
Registered: Sep 2011
Posts: 922

Rep: Reputation: 480Reputation: 480Reputation: 480Reputation: 480Reputation: 480
Quote:
Originally Posted by dederon View Post
1. There is Bash code in /etc/rc.d/rc.S.
2. This file has a "/bin/sh" shebang line, which is wrong.
Well, "wrong" might not the right term here. Slackware is the oldest surviving Linux distribution and predates most of what "modern" Linux distributions consider "right". Of course nowadays one might think, that /bin/sh should point to a real POSIX shell, so "bashisms" don't go by unnoticed. I agree with that.
Quote:
3. The fix is easy - change /bin/sh to /bin/bash.
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bashism in rc.udev - anyone uses ash as /bin/sh ? Camarade_Tux Slackware 3 03-02-2008 02:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 01:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration