coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Should I send a v2 patch?


From: Matheus Afonso Martins Moreira
Subject: Should I send a v2 patch?
Date: Tue, 07 Mar 2023 09:07:37 -0300

In response to feedback I received in another thread:

    https://lists.gnu.org/r/coreutils/2023-03/msg00002.html

I am prepared to write an updated patch if necessary.

Addressing the following concerns:

 - Bash already supports setting argv0

   It does and it almost worked. Unfortunately it introduces new variables,
   negating the use of env -i. Although I managed to unset the PWD variable,
   the SHLVL variable still persists. In the following example, program prints
   all arguments and environment variables:

       $ env -i bash -c 'exec -a program ./program'
       program
       PWD=/data/data/com.termux/files/home/dev/coreutils
       SHLVL=0

       $ env -i bash -c 'unset SHLVL; unset PWD; exec -a program ./program'
       program
       SHLVL=0

   I am not sure if this would be better addressed in bash or env.
   Please let me know if I should submit a patch to bash instead.

 - Using --title instead of --name

   I chose --name in order to be consistent with bash's functionality.

       exec [-a name] [command [arguments]]

       If -a is supplied, the shell passes name as the zeroth argument
       to the executed command.

   I am prepared to change the option if necessary.
   I also suggest -a and --argv0, the former being consistent with bash.

 - NULL argv[0]

   I would be glad to add support for this.
   I feel like an additional --null-argv0 option is the best implementation.
   Given that program arguments can be arbitrary NUL-terminated strings,
   if env were to parse a literal "NULL" as a directive to set argv[0] to 0,
   it would preclude the user from setting argv[0] to "NULL".
   An additional option would explicitly denote the special value.

 - zsh supports ARGV0

   I did find that possible solution in my searches.
   However, it suffers from the same problem as the bash solution:
   variables still persist despite env -i, many more than bash,
   even after being unset:

       $ env -i zsh -c 'unset _ HOME PWD LOGNAME SHLVL OLDPWD; ARGV0=program 
./program'
       program
       SHLVL=0
       _=/data/data/com.termux/files/home/dev/coreutils/./program

For these reasons I think this would be a good feature for env.
I apologize for any mistakes, I'm still getting used to using mailing lists.

Thank you for your consideration,

        Matheus Moreira



reply via email to

[Prev in Thread] Current Thread [Next in Thread]