Skip to content

Commit 45a6cc2

Browse files
committed
feat(entrypoint): add --env-bin option
for specifying the "env" executable. This is mostly for the automated test suite, as "/usr/bin/env" is not available within the test script environment.
1 parent 78e7c94 commit 45a6cc2

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

modules/devshell.nix

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,16 @@ let
122122
123123
PRJ_ROOT="$2"
124124
125+
shift
126+
;;
127+
--env-bin)
128+
if (( "$#" < 2 )); then
129+
echo 1>&2 '${cfg.name}: missing required argument to --env-bin'
130+
exit 1
131+
fi
132+
133+
env_bin="$2"
134+
125135
shift
126136
;;
127137
--)
@@ -146,6 +156,7 @@ let
146156
Options:
147157
* --pure : execute the script in a clean environment
148158
* --prj-root <path> : set the project root (\$PRJ_ROOT)
159+
* --env-bin <path> : path to the env executable (default: /usr/bin/env)
149160
USAGE
150161
exit
151162
fi
@@ -161,7 +172,7 @@ let
161172
# short-circuit options processing on the second pass through this
162173
# script, in case we get something like:
163174
# <entrypoint> --pure -- --pure <cmd>
164-
set -- /usr/bin/env -i -- ''${HOME:+"HOME=''${HOME:-}"} ''${PRJ_ROOT:+"PRJ_ROOT=''${PRJ_ROOT:-}"} "$0" -- "$@"
175+
set -- "''${env_bin:-/usr/bin/env}" -i -- ''${HOME:+"HOME=''${HOME:-}"} ''${PRJ_ROOT:+"PRJ_ROOT=''${PRJ_ROOT:-}"} "$0" -- "$@"
165176
else
166177
# Start a script
167178
source "$DEVSHELL_DIR/env.bash"

0 commit comments

Comments
 (0)