<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jan 12, 2023 at 1:40 PM Rob Landley <<a href="mailto:rob@landley.net">rob@landley.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 1/11/23 16:53, enh wrote:<br>
> ah, which is probably because you won't typically have $PWD set on Android...<br>
> <br>
> // If this isn't an absolute path, start with cwd or $PWD.<br>
> if (*path != '/') {<br>
> if ((flags & ABS_KEEP) && (str = getenv("PWD")))<br>
> splitpath(path, splitpath(str, &todo));<br>
> else {<br>
> splitpath(path, splitpath(str = xgetcwd(), &todo));<br>
> free(str);<br>
> }<br>
<br>
Which would explain the behavior difference, yes: getcwd() asks the OS for the<br>
current path to "." which is always going to be fully resolved, which means<br>
peeling off one member gives us the observed output.<br>
<br>
> } else splitpath(path, &todo);<br>
> <br>
> mksh fakes it so `echo $PWD` works, but there's no _exported_ $PWD:<br>
<br>
It's not faking it, it's setting the shell variable. But bash exports PWD by<br>
default (and thus so does toybox), but mksh doesn't.<br>
<br>
Toysh implemented the bash behavior and mksh... is mksh:<br>
<br>
$ env -i bash --noprofile --norc -c 'declare -p PWD'<br>
declare -x PWD="/home/landley/toybox/toybox"<br>
$ env -i ./sh --noprofile --norc -c 'declare -p PWD'<br>
declare -x PWD="/home/landley/toybox/toybox"<br>
$ env -i mksh --noprofile --norc -c 'declare -p PWD'<br>
mksh: mksh: --: unknown option<br>
<br>
I added an "export PWD" to the test, does that fix it?<br></blockquote><div><br></div><div>yeah, that passes for me locally. thanks!</div><div><br></div><div>worth adding explicit PWD-unset tests for the other codepath, since it exists?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Rob<br>
</blockquote></div></div>