You are not logged in.

#1 2010-03-14 17:15:52

TaylanUB
Member
Registered: 2009-09-16
Posts: 150

[SOLVED] Link /bin/sh to dash

Since dash is now in the core repo, why is '/bin/sh -> bash' not removed from the bash package, and a '/bin/sh -> dash' moved into the dash package?
From what i got after some searching, there's no particular issues [left] with default Arch/Pacman scripts using #!/bin/sh while making use of bashisms, but do you think it's still risky to use dash as /bin/sh?

Last edited by TaylanUB (2010-03-15 18:14:07)


``Common sense is nothing more than a deposit of prejudices laid down by the mind before you reach eighteen.''
~ Albert Einstein

Offline

#2 2010-03-14 22:15:23

sand_man
Member
From: Australia
Registered: 2008-06-10
Posts: 2,164

Re: [SOLVED] Link /bin/sh to dash

Because the initscripts are not compatible with dash. This has been discussed in depth many times.


neutral

Offline

#3 2010-03-14 22:45:34

fflarex
Member
Registered: 2007-09-15
Posts: 466

Re: [SOLVED] Link /bin/sh to dash

sand_man wrote:

Because the initscripts are not compatible with dash. This has been discussed in depth many times.

But like TaylanUB said, the initscripts all call /bin/bash now. None of them use /bin/sh.

Offline

#4 2010-03-14 23:27:15

sand_man
Member
From: Australia
Registered: 2008-06-10
Posts: 2,164

Re: [SOLVED] Link /bin/sh to dash

You lost me. You are asking why dash can't replace bash in the Arch initscripts? My understanding was that they only work with bash.
Has this changed?


neutral

Offline

#5 2010-03-14 23:31:11

fflarex
Member
Registered: 2007-09-15
Posts: 466

Re: [SOLVED] Link /bin/sh to dash

Nope, that's all correct. But you've misunderstood the question. Right now /bin/sh is a symlink to /bin/bash, and is provided in the bash package. The question is whether /bin/sh should be a symlink to /bin/dash instead, provided in the dash package. This shouldn't be a problem with any of the Arch scripts, because as far as I know, they all run as bash anyway, not sh.

I've tried doing it manually in the past but always ran into problems with pacman/makepkg. I tried it again just now and had trouble with X for some reason.

Last edited by fflarex (2010-03-14 23:35:44)

Offline

#6 2010-03-15 00:18:49

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,650
Website

Re: [SOLVED] Link /bin/sh to dash

Many of the Arch package .install scripts assume /bin/sh is bash...

Edit: makepkg uses /bin/bash so is not affected.

Online

#7 2010-03-15 00:55:17

sand_man
Member
From: Australia
Registered: 2008-06-10
Posts: 2,164

Re: [SOLVED] Link /bin/sh to dash

fflarex wrote:

Nope, that's all correct. But you've misunderstood the question. Right now /bin/sh is a symlink to /bin/bash, and is provided in the bash package. The question is whether /bin/sh should be a symlink to /bin/dash instead, provided in the dash package. This shouldn't be a problem with any of the Arch scripts, because as far as I know, they all run as bash anyway, not sh.

I've tried doing it manually in the past but always ran into problems with pacman/makepkg. I tried it again just now and had trouble with X for some reason.

Oh now I see what you mean. Sorry, it is a hazy Monday morning here tongue
I suppose it won't be much of a problem then but developers just need to know in the future that they will be using dash when specifying sh, otherwise will need to explicitly use bash. What it comes down to is, is it worth it? Plus what Allan just said. Not to mention many AUR packages they could possibly break also.

Last edited by sand_man (2010-03-15 00:56:00)


neutral

Offline

#8 2010-03-15 10:49:57

TaylanUB
Member
Registered: 2009-09-16
Posts: 150

Re: [SOLVED] Link /bin/sh to dash

@fflarex/Allan: Thanks for warning. Better not touch it then. People shouldn't be so careless about this issue though, IMO. (Just explicitly use #!/bin/bash; everything solved.)

@sand_man: When developers specify /bin/sh, they use /bin/sh (Bourne shell), and [d]ash is Bourne (and POSIX) compatible (and no more). The standard /bin/sh of other Unixen might not have non-standard features introduced by Bash, but they all must be at least POSIX/Bourne compatible, so when you use #!/bin/sh, it means your script is portable; if it isn't, don't mark it so... (Sadly, people do.)
Linking /bin/sh to dash makes sense because dash is more minimal (and thus fast); just enough for a script that claims Bourne shell compatibility. If you write a script using features specific to Bash, it should have #!/bin/bash anyway, so linking /bin/sh to dash is supposed not to break anything.


``Common sense is nothing more than a deposit of prejudices laid down by the mind before you reach eighteen.''
~ Albert Einstein

Offline

#9 2010-03-15 10:56:10

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,650
Website

Re: [SOLVED] Link /bin/sh to dash

TaylanUB wrote:

@fflarex/Allan: Thanks for warning. Better not touch it then. People shouldn't be so careless about this issue though, IMO. (Just explicitly use #!/bin/bash; everything solved.)

Or people should accept that in Arch /bin/sh is bash.

Online

#10 2010-03-15 11:44:02

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,002
Website

Re: [SOLVED] Link /bin/sh to dash

i'm pro using /bin/bash if you want bash features, /bin/sh if you want to use posix sh, and symlinking sh to dash as it's more lightweight.
although it looks like dash is not 100% posix sh compliant right now. see http://en.wikipedia.org/wiki/Debian_Almquist_shell


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#11 2010-03-15 16:01:20

TaylanUB
Member
Registered: 2009-09-16
Posts: 150

Re: [SOLVED] Link /bin/sh to dash

Do you think there's any chance that the dash in core will get a LINENO patch? (There are some (at least one i've seen) floating around.)

Allan wrote:

Or people should accept that in Arch /bin/sh is bash.

Isn't that forcing something non-standard onto the users?

Every *nix has a /bin/sh, and POSIX is the only reliable standard. If i mark my script #!/bin/sh, every standards-compliant /bin/sh should be able to run it, independent from the OS in use.
If you'll criticize POSIX or something like that, then it's another story; but even then, there's absolutely no reason not to just use #!/bin/bash if you use features found in Bash and not Bourne/Korn/[d]ash ... other than saving 16 bits per script, of course. =P


``Common sense is nothing more than a deposit of prejudices laid down by the mind before you reach eighteen.''
~ Albert Einstein

Offline

#12 2010-03-15 17:23:49

Bralkein
Member
Registered: 2004-10-26
Posts: 354

Re: [SOLVED] Link /bin/sh to dash

I try to mark my scripts as #!/bin/bash where they use bash features, and in an ideal world everyone else would do the same. However, we don't live in an ideal world and the unfortunate fact is that there are many shell scripts in use on Arch today where #!/bin/sh is used when it should refer to bash instead. Rather than spending ages messing about and causing all kinds of upheaval for some pointlessly minuscule speed gains, it is much simpler just to accept that this is the way things are and just move on.

Only my opinion, of course.

Offline

#13 2010-03-15 18:11:41

TaylanUB
Member
Registered: 2009-09-16
Posts: 150

Re: [SOLVED] Link /bin/sh to dash

Well, things can get fixed over time. It's enough for someone who comes to hear about this issue to pay care for the _next_ time; all they need to do is to type 'bash' instead of 'sh', if they're unsure.
Remind you that i opened the thread just to ask about this. Now i've learned it's unsafe to link /bin/sh to dash, and i'm not asking anyone to 'fix' something. (But i guess there's been a lot of debates before...)


Edit: Marked "solved" since the original question has been answered; better DON'T link /bin/sh to dash.

Last edited by TaylanUB (2010-03-15 18:15:13)


``Common sense is nothing more than a deposit of prejudices laid down by the mind before you reach eighteen.''
~ Albert Einstein

Offline

#14 2010-03-15 22:23:25

sand_man
Member
From: Australia
Registered: 2008-06-10
Posts: 2,164

Re: [SOLVED] Link /bin/sh to dash

TaylanUB wrote:

@fflarex/Allan: Thanks for warning. Better not touch it then. People shouldn't be so careless about this issue though, IMO. (Just explicitly use #!/bin/bash; everything solved.)

@sand_man: When developers specify /bin/sh, they use /bin/sh (Bourne shell), and [d]ash is Bourne (and POSIX) compatible (and no more). The standard /bin/sh of other Unixen might not have non-standard features introduced by Bash, but they all must be at least POSIX/Bourne compatible, so when you use #!/bin/sh, it means your script is portable; if it isn't, don't mark it so... (Sadly, people do.)
Linking /bin/sh to dash makes sense because dash is more minimal (and thus fast); just enough for a script that claims Bourne shell compatibility. If you write a script using features specific to Bash, it should have #!/bin/bash anyway, so linking /bin/sh to dash is supposed not to break anything.

Thanks for enlightening me.


neutral

Offline

Board footer

Powered by FluxBB