[Toybox] macOS realpath test failures
enh
enh at google.com
Thu Jan 12 14:19:29 PST 2023
On Thu, Jan 12, 2023 at 1:40 PM Rob Landley <rob at landley.net> wrote:
> On 1/11/23 16:53, enh wrote:
> > ah, which is probably because you won't typically have $PWD set on
> Android...
> >
> > // If this isn't an absolute path, start with cwd or $PWD.
> > if (*path != '/') {
> > if ((flags & ABS_KEEP) && (str = getenv("PWD")))
> > splitpath(path, splitpath(str, &todo));
> > else {
> > splitpath(path, splitpath(str = xgetcwd(), &todo));
> > free(str);
> > }
>
> Which would explain the behavior difference, yes: getcwd() asks the OS for
> the
> current path to "." which is always going to be fully resolved, which means
> peeling off one member gives us the observed output.
>
> > } else splitpath(path, &todo);
> >
> > mksh fakes it so `echo $PWD` works, but there's no _exported_ $PWD:
>
> It's not faking it, it's setting the shell variable. But bash exports PWD
> by
> default (and thus so does toybox), but mksh doesn't.
>
> Toysh implemented the bash behavior and mksh... is mksh:
>
> $ env -i bash --noprofile --norc -c 'declare -p PWD'
> declare -x PWD="/home/landley/toybox/toybox"
> $ env -i ./sh --noprofile --norc -c 'declare -p PWD'
> declare -x PWD="/home/landley/toybox/toybox"
> $ env -i mksh --noprofile --norc -c 'declare -p PWD'
> mksh: mksh: --: unknown option
>
> I added an "export PWD" to the test, does that fix it?
>
yeah, that passes for me locally. thanks!
worth adding explicit PWD-unset tests for the other codepath, since it
exists?
> Rob
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20230112/2187b1d6/attachment.htm>
More information about the Toybox
mailing list