coreutils
[Top][All Lists]
Advanced

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

env: please add argv0 setting feature


From: matheus . a . m . moreira
Subject: env: please add argv0 setting feature
Date: Thu, 02 Mar 2023 09:34:20 -0300

I'm using env to control a program's environment for testing purposes.
It allows me control over arguments, environment and input.

    env -i VARIABLE=value program argv1 argv2 argv3

However, I also need control over the program name located at argv0.

    # argv0 is set to "./program"
    env -i VARIABLE=value ./program argv1 argv2 argv3

I'd like to normalize it to "program" for testing purposes.
I'd also like to be able to set it to other values.
So it would be useful if env had support for it. Something like:

    env --name program -i VARIABLE=value ./program argv1 argv2 argv3

I tried to use bash for this but it didn't turn out well.

    # Sets PWD and SHLVL and the latter apparently can't be unset
    env -i VARIABLE=value bash -c 'exec -a program ./program'

    # Sets env's argv0, not my program's
    bash -c 'exec -a program env -i VARIABLE=value ./program'

Are you open to receiving a patch for this feature?



reply via email to

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