You are not logged in.

#1 2019-04-25 11:13:02

magicloud
Member
Registered: 2014-06-17
Posts: 48

[SOLVED]What should /bin/sh actually be?

In my system, not sure if anything I did wrong, /bin/sh was linked to /usr/bin/bash. It all worked well until I found that VIM parsed shell script wrong.

Hence I changed the link to /usr/bin/busybox. But this triggered new problem. When `man` calls subprocess `nroff` via /bin/sh, /bin/sh crashes with something about seccomp. Environment MAN_DISABLE_SECCOMP helps.

So, what should /bin/sh be?

Last edited by magicloud (2019-04-25 12:17:10)

Offline

#2 2019-04-25 11:16:53

loqs
Member
Registered: 2014-03-06
Posts: 17,192

Re: [SOLVED]What should /bin/sh actually be?

$ pacman -Qo /usr/bin/sh
/usr/bin/sh is owned by bash 5.0.003-1
$ pacman -Qkk bash
bash: 241 total files, 0 altered files

sh is provided by bash on arch.

Offline

#3 2019-04-25 11:23:29

magicloud
Member
Registered: 2014-06-17
Posts: 48

Re: [SOLVED]What should /bin/sh actually be?

loqs wrote:
$ pacman -Qo /usr/bin/sh
/usr/bin/sh is owned by bash 5.0.003-1
$ pacman -Qkk bash
bash: 241 total files, 0 altered files

sh is provided by bash on arch.

Yes, and it is a link to bash. So if I used /bin/sh as /usr/bin/sh, I would get the VIM problem again.

Offline

#4 2019-04-25 11:27:11

loqs
Member
Registered: 2014-03-06
Posts: 17,192

Re: [SOLVED]What should /bin/sh actually be?

https://en.wikipedia.org/wiki/XY_problem

You have not provided details of "VIM parsed shell script wrong" or solutions you tried apart from changing sh to point to busybox.

Edit:
/bin should be a symlink to /usr/bin so using /bin/sh or /usr/bin/sh should not make a difference.

Last edited by loqs (2019-04-25 11:29:11)

Offline

#5 2019-04-25 11:27:43

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,868

Re: [SOLVED]What should /bin/sh actually be?

I would get the VIM problem again.

Maybe you could describe the vim problem and ask for help with it ?


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#6 2019-04-25 11:43:19

magicloud
Member
Registered: 2014-06-17
Posts: 48

Re: [SOLVED]What should /bin/sh actually be?

loqs wrote:

You have not provided details of "VIM parsed shell script wrong" or solutions you tried apart from changing sh to point to busybox.

Lone_Wolf wrote:

Maybe you could describe the vim problem and ask for help with it ?

That is another thread here, that a script got different syntax highlight in VIM between Archlinux and Ubuntu/Fedora. And the root cause is that /bin/sh was `bash`. The problem was solved by linking /bin/sh to busybox. But apparently, busybox is not the correct answer, either. I mean it works there, but not here.

I know Ubuntu sh links to dash, but wondering what is the proper one for Archlinux.

Offline

#7 2019-04-25 11:51:51

loqs
Member
Registered: 2014-03-06
Posts: 17,192

Re: [SOLVED]What should /bin/sh actually be?

Now you know that arch provides and expects /usr/bin/sh to be linked bash perhaps you should mark this thread as [SOLVED] and remove [SOLVED] from https://bbs.archlinux.org/viewtopic.php?id=245817

Last edited by loqs (2019-04-25 11:52:08)

Offline

#8 2019-04-25 12:02:15

magicloud
Member
Registered: 2014-06-17
Posts: 48

Re: [SOLVED]What should /bin/sh actually be?

loqs wrote:

Now you know that arch provides and expects /usr/bin/sh to be linked bash perhaps you should mark this thread as [SOLVED] and remove [SOLVED] from https://bbs.archlinux.org/viewtopic.php?id=245817

No, I don't. The VIM issue clearly says bash causes problem. And this clearly says busybox sh causes problem. So I wonder if, as a Distro, there is a Archlinux choice for /bin/sh.

Offline

#9 2019-04-25 12:02:34

frostschutz
Member
Registered: 2013-11-15
Posts: 1,409

Re: [SOLVED]What should /bin/sh actually be?

if you know that your shell script will only work with bash, it should have #!/bin/bash and not #!/bin/sh and blindly assume it will be bash, as that is not true on all systems

/bin/sh can be any shell ( should be posix compatible )

The problem was solved by linking /bin/sh to busybox.

While busybox in initramfs or embedded systems is fine, I would never use it as a default shell on a desktop system.

Busybox scripts have to be developed and tested with busybox in mind, there can be odd behavior or outright bugs.

If you really need a replacement, perhaps try your luck with https://wiki.archlinux.org/index.php/Dash

Offline

#10 2019-04-25 12:16:55

magicloud
Member
Registered: 2014-06-17
Posts: 48

Re: [SOLVED]What should /bin/sh actually be?

frostschutz wrote:

if you know that your shell script will only work with bash, it should have #!/bin/bash and not #!/bin/sh and blindly assume it will be bash, as that is not true on all systems

/bin/sh can be any shell ( should be posix compatible )

The problem was solved by linking /bin/sh to busybox.

While busybox in initramfs or embedded systems is fine, I would never use it as a default shell on a desktop system.

Busybox scripts have to be developed and tested with busybox in mind, there can be odd behavior or outright bugs.

If you really need a replacement, perhaps try your luck with https://wiki.archlinux.org/index.php/Dash

Sorry, it is not that my script does not. It's how VIM parse and highlight scritp text.

And so you are suggesting dash as well. Well, that'd be it.

Offline

#11 2019-04-25 12:47:44

seth
Member
Registered: 2012-09-03
Posts: 49,974

Re: [SOLVED]What should /bin/sh actually be?

Stop trying to bend the universe around your broken script.

If anything the vim highlighter needs to get "smarter" and take into account the specific behavior of bash (though it's more than questionable to resolve /bin/sh to determine the sytax, if the shebang is /bin/sh it should be a POSIX shell script, free of bashisms - broken or not) in this context.

The idea to rename or relink the shebang destination in order to trick the highlighter to enter a more simplistic path that accidentally doesn't stumble on your wonky expression is completely nuts and a recipe for more trouble down the road.
As you noticed and you're apparently guilty of yourself: half the universe blindly relies on /bin/sh being /bin/bash, so deviating from that will just get you trouble.

Online

#12 2019-04-25 17:58:34

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,442
Website

Re: [SOLVED]What should /bin/sh actually be?

seth wrote:

half the universe blindly relies on /bin/sh being /bin/bash, so deviating from that will just get you trouble.

I link /bin/sh to ash and I have no real problems.  Any member of that half of the universe that writes a script with a /bin/sh shebang and uses non-POSIX features is just wrong and any arch package that has that assumption should be reported as a bug.  I don't know of any in the repos that make this mistake: may use bash, and I'm frustrated when they specify bash in the shebang when it's not needed, but none that I know of fail to specify bash when it is needed.

seth wrote:

Stop trying to bend the universe around your broken script.

This part in contrast, I completely agree with.  OP, you have a bash script that is highlighted correctly when you have a bash shebang.  Or you have gibberish that is not highlighted the way you want when it has a /bin/sh shebang.  So your concern is that vim does not highlight gibberish the way you'd like your gibberish to be highlighted.  Tough.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#13 2019-04-25 19:50:48

seth
Member
Registered: 2012-09-03
Posts: 49,974

Re: [SOLVED]What should /bin/sh actually be?

Well, there's a universe beyond the arch repos ;-)
And yes, those are of course all bugs, but they happen - a lot.

https://www.google.com/search?q=bashism+bug

Online

Board footer

Powered by FluxBB