You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi!
I am writing a Rust program that installs a POSIX shell script. In order to configure the shebang line properly, I would like to follow the spec and resolve the absolute sh path.
Furthermore, on systems that support executable scripts (the "#!" construct), it is recommended that applications using executable scripts install them using getconf PATH to determine the shell pathname and update the "#!" script appropriately as it is being installed (for example, with sed).
This behavior is close enough to which (but not quite the same) that I feel that this crate would be the best place to implement it. I propose adding a posix_sh function returning the absolute path to the posix shell found this way.
The main difference is that the resolution should not use the PATH environment variable but use the getconf function to retrieve PATH (so it is not subject to user-made changes to the PATH variable, for example in a situation where the process is spawned without environment variables).
This difference in behavior is slightly subtle, having this logic built-in here would make it easier for other devs to discover and use.
I am willing to send a PR for this feature if it is OK.
Regarding the implementation, I'd use a platform check to enable this function only on platforms supporting getconf.
The text was updated successfully, but these errors were encountered:
Thanks for the feedback, I'll look into sending a PR in this case.
While prototyping it in my main project, I also found that it would be useful to support not only sh but other POSIX utilities but it does not change much from the implementation point of view.
Hi!
I am writing a Rust program that installs a POSIX shell script. In order to configure the shebang line properly, I would like to follow the spec and resolve the absolute
sh
path.https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sh.html#tag_20_117_16
This behavior is close enough to
which
(but not quite the same) that I feel that this crate would be the best place to implement it. I propose adding aposix_sh
function returning the absolute path to the posix shell found this way.The main difference is that the resolution should not use the
PATH
environment variable but use thegetconf
function to retrievePATH
(so it is not subject to user-made changes to thePATH
variable, for example in a situation where the process is spawned without environment variables).This difference in behavior is slightly subtle, having this logic built-in here would make it easier for other devs to discover and use.
I am willing to send a PR for this feature if it is OK.
Regarding the implementation, I'd use a platform check to enable this function only on platforms supporting
getconf
.The text was updated successfully, but these errors were encountered: