New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
/bin/sh
& /run/current-system/sw/bin/sh
is symlinked to a shell with bash-isms
#74627
Comments
As far as I know this is more of pragmatic convention, rather than principal decision. Related #1424 (comment) Purifying nixpkgs from bashisms is fine in what you've described. The main problem is actually make it work, and to find nixpkgs maintainers who would like to review such purifications. For example, to test this one should setup an extra Hydra jobset to rebuild world with /bin/sh pointed to dash. We occasionally get I haven't tried replacing /bin/sh with dash. Have you tried? Does system build/work fine? |
We occasionally get `/bin/sh` problems with some packages, which don't expect Bash being there. So far it wasn't very common issue, maybe that's why it is not pursued by maintainers.
All problems I have seen were caused by /bin/sh _not_ being Bash, and they were numerous enough that the decision was to not care and use Bash again.
I haven't tried replacing /bin/sh with dash. Have you tried? Does system build/work fine?
Note that one can replace the normal /bin/sh and the build sandbox /bin/sh separately
|
Thank you for your contributions. This has been automatically marked as stale because it has had no activity for 180 days. If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity. Here are suggestions that might help resolve this more quickly:
|
This is still important to me, symlinking https://wiki.archlinux.org/index.php/Dash#Use_DASH_as_/bin/sh |
Do you know where is the symlinking of /bin/sh happening in NixOS? I couldn't find it anywhere in the sources. |
There's this option that lets you replace the https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/config/shells-environment.nix#L129-L143 But every file that was IIRC when I had the option on even |
Thank you, I'll give it a try. |
I marked this as stale due to inactivity. → More info |
Describe the bug
Why is
/bin/sh
linked tobash
instead of a "real"sh
?nixpkgs/nixos/modules/config/shells-environment.nix
Lines 139 to 140 in 0c3a28f
If
bash
is truly needed it should refer to/usr/bin/env bash
or I guess/bin/bash
if it was added alongside existing/bin/sh
?I've seen several explanations saying
/bin/sh
exists because POSIX requires it (sounds like compliance to me) but/bin/bash
isn't required so it doesn't exist on nixos systems to make it visible when things try to hit/bin/bash
and help map dependencies ...https://discourse.nixos.org/t/thoughts-from-a-new-nixos-user/2135/14
But then
/bin/sh
isn't the actual POSIX compliantsh
and is in-fact non-POSIX compliant GNU Bash. So you can erroneously list ash
dependency but due to using double square brackets[[
you'd actually have abash
(or some other shell that supports[[
).If someone could give me an explanation as to why this is the case that'd be great.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
I expect
/bin/sh
(and/run/current-system/sw/bin/sh
) to not have bash-isms.If
bash
is needed can't we just use/usr/bin/env bash
or add a/bin/bash
symlink etc...(I have seen methods to change
/bin/sh
[with the warnings] but it seems like there's no official way to swap out/run/current-system/sw/bin/sh
and I'd guess it'd be even more potentially destructive)It seems very arbitrary that
/bin/bash
shouldn't exist to help map dependencies but if I have a module withbash
scripts hittingsh
everything will still run just fine and there's no proper dependency mapping there. And that's excluding the principal that POSIX required shell should probably be a POSIX shell so that I can easily swap it out for something else likedash
as you'd expect if all dependencies are mapped.The fact that I can't put a POSIX shell in the position of
/bin/sh
means that dependencies simply are not being mapped in this case.Anyway I'd love to hear peoples thoughts. I haven't been around nixos that long so I can't exactly waltz in and assert this is now nixos should be to meet its mission statement.
If nixos is commited to treating
/bin/sh
as abash
shell then I guess I'll just swap outsh
at the level of my user rather than at the system level.The text was updated successfully, but these errors were encountered: