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
Do not assume a path to the sh and env binaries #528
Conversation
This improves portability, specifically for non-rooted Android devices which lacks /bin and /usr folders.
This also breaks installs where PATH is scrubbed before this is run. |
Do you know of any such install (or have ever encountered one) with I have been pushing in some changes in various projects that replaces
There are system binaries in
Would something like the below be ok to determine which SHELL=/bin/sh
if [ ! -x /bin/sh ]; then SHELL=sh; fi |
/usr/bin/env and /bin/sh are standard locations across Unix like systems. Any widely distributed, mildly cross-platform shell script will use the following shebang:
The assumed shell in every unix-like system I've used is Fallback to relying on |
I tried it myself locally with Termux, it failed to build:
|
Where are |
They are under Would something like this be fine (if the check for certain paths is still desired)? SH=sh
ENV=env
if [ -x /bin/sh ]; then SH=/bin/sh; fi
if [ -x /usr/bin/env ]; then ENV=/usr/bin/env; fi And then use |
Probably just use env vars to override their location. Not sure why I didn't think of that earlier. Test the env var then test the standard path and finally fall back to |
@tduehr Like this? ENV=${ENV:-/usr/bin/env}
SH=${SH:-/bin/sh}
if [ ! -x "$SH" ]; then SH=sh; fi
if [ ! -x "$ENV" ]; then ENV=env; fi |
Yup |
Upon further research... |
This improves portability, specifically for non-rooted Android devices which lacks /bin and /usr folders.