[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: env: follow up on argv0 setting feature
From: |
Pádraig Brady |
Subject: |
Re: env: follow up on argv0 setting feature |
Date: |
Thu, 21 Mar 2024 15:08:42 +0000 |
User-agent: |
Mozilla Thunderbird |
On 20/03/2024 23:19, Pádraig Brady wrote:
On 13/03/2024 10:19, Matheus Afonso Martins Moreira wrote:
About a year ago, I posted an env feature request on this list:
the ability to set the value of argv[0].
https://lists.gnu.org/archive/html/coreutils/2023-03/msg00002.html
I also sent a patch:
https://lists.gnu.org/archive/html/coreutils/2023-03/msg00003.html
After some discussion, I was informed it was under consideration:
https://lists.gnu.org/archive/html/coreutils/2023-03/msg00012.html
We're still considering and will adjust as needed.
I waited a while and eventually sent an email about it:
https://lists.gnu.org/archive/html/coreutils/2023-08/msg00059.html
The maintainer noted that they expected this feature to be included
in the next release which would be focused on features:
https://lists.gnu.org/archive/html/coreutils/2023-08/msg00060.html
The next release will focus on new features, and this
will be considered. I expect this feature will be included.
Since then I've been tracking commits to the coreutils master branch
but it appears the feature has not landed yet.
What happened? Was it rejected?
Thanks for your patience.
I've attached an implementation for --argv0
which I intend to apply for the impending release.
Note this can accept empty and NULL values,
and so now gives env full control of the args it passes on.
In testing this on a newer Linux kernel I see that argv[0] == NULL
is converted to an empty string instead.
That was one of the proposals at https://lwn.net/Articles/882799/
and I see it was implemented on kernels >= 5.18:
https://github.com/torvalds/linux/commit/dcd46d89
So in retrospect it's probably not worth supporting a NULL argv0,
as newer kernels won't pass it. Also with a NULL argv0,
the kernel puts the environ array directly after the first NULL,
and so will discard any other params passed to env,
which would be confusing to users.
Version 2 attached, now makes --argv0 require an argument.
thanks,
Pádraig.
env--argv0.patch
Description: Text Data