Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#8 (comment)
parent=$(ps -o comm $PPID |tail -1)
will break docker build witherror: process ID out of range
if/bin/sh
is actuallybash
orbash
is explicitly used.Reason:
RUN ["/bin/bash", "-c", "/bin/bash <(curl -L micro.mamba.pm/install.sh)"]
will cause the shell environment has$$=1
and$PPID=0
.As discussed in https://stackoverflow.com/questions/77524391/ppid-behavior-of-bash-c-and-dockerfile-run , https://stackoverflow.com/questions/67827986/why-is-bash-handling-child-processes-different-compared-to-sh, https://stackoverflow.com/questions/76310409/does-bash-promise-to-optimize-c-into-plain-exec-in-simple-cases, and https://unix.stackexchange.com/a/466523/537347,
bash
will introduce optimization thatexec
the last command and make$$=1
(considering the PID namespace mechanism of container).RUN ["/bin/bash", "-c", "(/bin/bash <(curl -L micro.mamba.pm/install.sh))"]
(i.e. create a subshell) orRUN ["/bin/bash", "-c", "/bin/bash <(curl -L micro.mamba.pm/install.sh); exit"]
can work.It seems that we should fallback to
$$
if$PPID
is not exists of is not a compatible shell.As discussed in #8 (comment), for non-POSIX compliant shell for example
fish
andxonsh
,install.sh
might be executed bybash
orsh
. Thus we cannot use$$
by default.However, using
$PPID
instead of$$
does introduce counter-intuitive behavior: runzsh <(curl -L micro.mamba.pm/install.sh)
in abash
will initbash
.Instruction in the documentation (and README of this repo)
"${SHELL}" <(curl -L https://micro.mamba.pm/install.sh)
does NOT always usesh
, suggesting that"${SHELL}"
will be initialized (but actually NOT). And there isn't any remark/note around this instruction.Nonetheless, allow something like
INIT_WHICH_SHELL
(in{bash,cmd.exe,dash,fish,posix,powershell,tcsh,xonsh,zsh}
) to be set before the script is run to facilitate non-interactive installation can be really helpful.cc @AntoinePrv