RFE for 'env'?

  • Open
  • quality assurance status badge
Details
2 participants
  • Erik Auerswald
  • L A Walsh
Owner
unassigned
Submitted by
L A Walsh
Severity
normal
L
L
L A Walsh wrote on 4 Nov 2020 16:27
(name . Bernhard Voelker)(address . mail@bernhard-voelker.de)(name . Coreutils)(address . bug-coreutils@gnu.org)
5FA2C855.7080402@tlinx.org
Rewriting this bug as the other one, apparently, was too unclear
to be understood.

This gives an example, two in fact.


On 2020/11/03 14:48, Bernhard Voelker wrote:
Toggle quote (5 lines)
> On 11/3/20 6:29 PM, L A Walsh wrote:
>> I tried to use 'env' to find perl in my path and wanted to pass
>> the -T option to perl.
>>
>> cat >/tmp/taint+print
#!/usr/bin/env perl -T
printf "Hello World\n";

I am unable to get this to run and print out:

"Hello World" \

Instead of expected output, I get:
/usr/bin/env: ‘perl -T’: No such file or directory


So I tried turning off env's arg parsing as we know the linux kernel
does handle this.

#!/usr/bin/env -- perl -T
/usr/bin/env: unrecognized option '-- perl -T'
Try '/usr/bin/env --help' for more information.

I am not able find a syntax that will generate what I want.

1) '--' isn't handled as being the end of 'env' arguments
2) It isn't splitting white-space to to generate separate arguments
but seems to concatenate together as 1 argument.
3) This overrides normal linux kernel behavior. This is a kernel policy
that is overridden by a user-level program.

*>>* If these behaviors were under user control, I don't think it would be a
problem. While some utils/progs like "find" tend to ignore symlinks
unless they are on the command line. Others, like bash, by default,
try to give a logical view by following the symlinks and restoring when
backing out. Both options can have utility. find even has suboptions for
ignoring their use on the cmdline, but expanding them in subtrees.

Toggle quote (2 lines)
> Bernhard V. Thanks, so it seems 'env' works as expected and
> supports the way you need it to run.
---
Hopefully you understand you had it backwards -- in that it doesn't
work as expected (doesn't break arguments in same places as kernel). and does
not support the way I need it to run.

Do to your misunderstanding you closed the original bug -- Hopefully it is
clear explained enough so this note won't also get deleted.


Toggle quote (2 lines)
> Have a nice day,
> Berny
----
Trying -- at least elections are over.
E
E
Erik Auerswald wrote on 4 Nov 2020 17:09
(name . L A Walsh)(address . coreutils@tlinx.org)
20201104160934.GA3976@unix-ag.uni-kl.de
Hi,

On Wed, Nov 04, 2020 at 07:27:17AM -0800, L A Walsh wrote:
Toggle quote (22 lines)
> Rewriting this bug as the other one, apparently, was too unclear
> to be understood.
>
> This gives an example, two in fact.
>
>
> On 2020/11/03 14:48, Bernhard Voelker wrote:
> >On 11/3/20 6:29 PM, L A Walsh wrote:
> >> I tried to use 'env' to find perl in my path and wanted to pass
> >>the -T option to perl.
> >>
> >>cat >/tmp/taint+print
> #!/usr/bin/env perl -T
> printf "Hello World\n";
>
> I am unable to get this to run and print out:
>
> "Hello World" \
>
> Instead of expected output, I get:
> /usr/bin/env: ‘perl -T’: No such file or directory

That is not env, that is the Linux kernel providing 'perl -T' as single argument to env.

$ cat taint+print
#!/usr/bin/env perl -T
printf "Hello World\n";
$ ./taint+print
/usr/bin/env: ‘perl -T’: No such file or directory
$ /usr/bin/env perl -T taint+print
Hello World
$

Please see
for an explanation.

HTH,
Erik
--
Ow, you made me look at perl code.
-- Andrew Morton
L
L
L A Walsh wrote on 5 Nov 2020 20:41
(name . Erik Auerswald)(address . auerswal@unix-ag.uni-kl.de)
5FA45578.5020006@tlinx.org
Ah...so what I asked for has already been added in a newer version.

I seem to have > env --version
env (GNU coreutils) 8.26.18-5e871

What version of env should I try and test?


Thanks!


On 2020/11/04 08:09, Erik Auerswald wrote:
Toggle quote (6 lines)
> Please see
> https://www.gnu.org/software/coreutils/manual/html_node/env-invocation.html#g_t_002dS_002f_002d_002dsplit_002dstring-usage-in-scripts
> for an explanation.
>
> HTH,
> Erik
E
E
Erik Auerswald wrote on 6 Nov 2020 09:57
(name . L A Walsh)(address . coreutils@tlinx.org)
20201106085713.GB16160@unix-ag.uni-kl.de
Hi,

On Thu, Nov 05, 2020 at 11:41:44AM -0800, L A Walsh wrote:
Toggle quote (12 lines)
> On 2020/11/04 08:09, Erik Auerswald wrote:
> >Please see
> >https://www.gnu.org/software/coreutils/manual/html_node/env-invocation.html#g_t_002dS_002f_002d_002dsplit_002dstring-usage-in-scripts
> >for an explanation.
>
> Ah...so what I asked for has already been added in a newer version.
>
> I seem to have > env --version
> env (GNU coreutils) 8.26.18-5e871
>
> What version of env should I try and test?

According to the NEWS file, env from Coreutils 8.30 introduced this option.

Thanks,
Erik
--
Thinking doesn't guarantee that we won't make mistakes. But not thinking
guarantees that we will.
-- Leslie Lamport
?