fix: use absolute path for /bin/sh - #317
Conversation
|
I'm not sure hardcoding /bin/sh is a best practice. Whats your $PATH? It doesn't have /bin in it ? |
I'm on NixOS so I can easily find hundreds of other examples if you're not convinced. In fact, this pattern is so ubiquitous that |
|
I agree that /bin/sh is ubiquitous, but I'm not sure it's the right solution because of a few reasons:
I'm not sure what's the correct answer, but IME, hardcoding assumptions can cause even more trouble, maybe we should explore more how we can leverage the system as it is designed (e.g. by having a correct $PATH set for the system, or maybe by using You suggest that on NixOS, sh is in /bin, but the $PATH does not include /bin, then perhaps that is the root cause? The way this works on Arch is that /bin is symlinked to /bin/sh. |
Okay, I'll address your concerns in order:
Is there any specific concern you have over this change? In my opinion, a pretty compelling reason would be needed to break from the ubiquitous standard across Linux applications (such as any that call to system(3)). |
I'm not implying anything. I'm trying to have a productive conversation around what the best solution is, and that includes bringing up questions/considerations and considering alternative approaches. It may be that hardcoding /bin/sh is the best solution. I have no opinion yet.
it seems to me that any distro implementing systemd should also implement what is described in https://man.archlinux.org/man/systemd.exec.5.en#Environment_Variables_Set_or_Propagated_by_the_Service_Manager so that systemd can do its job properly. I consider that proper setup, not a workaround. It's totally possible that i'm missing something, but it seems worth looking into first why on NixOS binaries are "invisible" because they are in directories that are not included in the systemd path. Perhaps it's a bug that needs fixing, or perhaps it's done deliberately for some reason. In which case hardcoding /bin/sh seems indeed like a good choice. |
I apologize for my tone, I did not mean to come off as passive-aggressive. If the goal is to interpret shell scripts with a POSIX compatible shell, my claim is that hardcoding By the way, there is a good reason is that things are done this way instead of by resolving If you strongly disagree with |
👍 appreciated. seems just using /bin/sh is indeed fine. We may want to add notices to the documentation that when configuring commands, only posix sh syntax is allowed. (we still don't agree re: systemd but that has become a separate topic at this point, no need to continue discussing that) |
Previously Wayle would resolve
shfrom the$PATH, which was problematic when in minimal environments (i.e. run from a systemd service). For this reason, the most common---and generally best---practice is to call the standardized FHS absolute path (/bin/sh) directly.