On 04/03/2020 16:30, Marius Bakke wrote:
Pádraig Brady <[email protected]> writes:

On 04/03/2020 14:46, Pádraig Brady wrote:
On 04/03/2020 13:44, Marius Bakke wrote:
Pádraig Brady <[email protected]> writes: >>
I don't see /bin/env being used here.

Really?  Can you send a trace of 'make check TESTS=tests/misc/env-S.pl'?
Curious how it is supposed to work...

Oops I typod my grep. I do see the /usr/bin/env now.
The reason is, where we run env with -i the PATH is cleared,
and the system then falls back to default paths:

$ strace -e execve src/env -i A=B env
execve("src/env", ["src/env", "-i", "A=B", "env"], 0x7ffcfede1638 /* 65 vars 
*/) = 0
execve("/usr/bin/env", ["env"], 0x1cfa380 /* 1 var */) = 0
A=B

We could avoid that by specifying the path to our built env(1) instead.
I'll look at doing something with $abs_top_builddir/src/env

The attached should address this I think.

Thanks!  It fixed most of the failing tests, but missed the first five:

FAIL: tests/misc/env-S
======================

env (GNU coreutils) 8.31.99-f2034
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Richard Mlynarik, David MacKenzie, and Assaf Gordon.
1...
env-S.pl: test 1 failed: exit status mismatch:  expected 0, got 127
2...
env-S.pl: test 2 failed: exit status mismatch:  expected 0, got 127
3...
env-S.pl: test 3 failed: exit status mismatch:  expected 0, got 127
4...
env-S.pl: test 4 failed: exit status mismatch:  expected 0, got 127
5...
env-S.pl: test 5 failed: exit status mismatch:  expected 0, got 127

Oh right. They're not looking for `env`, but they do clear the PATH,
and so wouldn't be able to find `sh` for the same reasons.
We could take a different approach there and not clear the PATH
with the attached, which is in addition to the previous patch

thanks for the quick testing.
Pádraig
diff --git a/tests/misc/env-S.pl b/tests/misc/env-S.pl
index 1f3740b68..504bb5d6c 100755
--- a/tests/misc/env-S.pl
+++ b/tests/misc/env-S.pl
@@ -33,11 +33,11 @@ $env = $1;
 my @Tests =
     (
      # Test combination of -S and regular arguments
-     ['1', q[-i    A=B FOO=AR  sh -c 'echo $A$FOO'],      {OUT=>"BAR"}],
-     ['2', q[-i -S'A=B FOO=AR  sh -c "echo \\$A\\$FOO"'], {OUT=>"BAR"}],
-     ['3', q[-i -S'A=B FOO=AR' sh -c 'echo $A$FOO'],      {OUT=>"BAR"}],
-     ['4', q[-i -S'A=B' FOO=AR sh -c 'echo $A$FOO'],      {OUT=>"BAR"}],
-     ['5', q[-S'-i A=B FOO=AR sh -c "echo \\$A\\$FOO"'],  {OUT=>"BAR"}],
+     ['1', q[-ufoo    A=B FOO=AR  sh -c 'echo $A$FOO'],      {OUT=>"BAR"}],
+     ['2', q[-ufoo -S'A=B FOO=AR  sh -c "echo \\$A\\$FOO"'], {OUT=>"BAR"}],
+     ['3', q[-ufoo -S'A=B FOO=AR' sh -c 'echo $A$FOO'],      {OUT=>"BAR"}],
+     ['4', q[-ufoo -S'A=B' FOO=AR sh -c 'echo $A$FOO'],      {OUT=>"BAR"}],
+     ['5', q[-S'-ufoo A=B FOO=AR sh -c "echo \\$A\\$FOO"'],  {OUT=>"BAR"}],
 
      # Test quoting inside -S
      ['q1', q[-S'-i A="B C" ]."$env'",       {OUT=>"A=B C"}],

Reply via email to