Skip to content

fix package manager detection in dash shell#63

Merged
ThatOneCalculator merged 1 commit into
ThatOneCalculator:mainfrom
rrotter:rrotter/dash_support
Jun 5, 2025
Merged

fix package manager detection in dash shell#63
ThatOneCalculator merged 1 commit into
ThatOneCalculator:mainfrom
rrotter:rrotter/dash_support

Conversation

@rrotter
Copy link
Copy Markdown
Contributor

@rrotter rrotter commented Jun 4, 2025

POSIX does not require that command accept more than one parameter. Because dash silently ignores additional parameters, replacement of which with command -v resulted in dash (which is the default /bin/sh on Debian and Ubuntu) ignoring all package managers except nix-env (the first one on the list).

This PR resolves the issue by using a for loop around command -v, which should work in any POSIX shell. hyperfine shows this to be just as fast as the previous code, keeping the speedup from dropping which.

Reference: https://pubs.opengroup.org/onlinepubs/009696899/utilities/command.html
Resolves: #59

POSIX does not require that `command` accept more than one parameter.
Because `dash` silently ignores additional parameters, replacement
of `which` with `command -v` resulted in `dash` (which is the default
`/bin/sh` on Debian and Ubuntu) ignoring all package managers except
nix-env (the first one on the list).
@rrotter
Copy link
Copy Markdown
Contributor Author

rrotter commented Jun 5, 2025

Pushed to add proofreading changes to my commit message. Content unchanged from 51f0f32 to c91319d.

@ThatOneCalculator
Copy link
Copy Markdown
Owner

Thank you! Will be making a new release with this + #64

@ThatOneCalculator ThatOneCalculator merged commit 6328ab4 into ThatOneCalculator:main Jun 5, 2025
@rrotter rrotter deleted the rrotter/dash_support branch June 5, 2025 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

error: getting status of '/run/current-system/sw': No such file or directory

2 participants