In a C program I can write argv[0] and the new name shows up in a ps listing.
How can I do this in bash?
One of the requirements I have is that the script must be self contained; no other files are to accompany the script and there are to be no environment variables. This would require the script to be able to edit itself.
From man bash : -s If the -s option is present, or if no arguments remain after option processing, then commands are read from the standard input. This option allows the positional parameters to be set when invoking an interactive shell.
You can do it when running a new program via exec -a <newname>
.
Just for the record, even though it does not exactly answer the original poster's question, this is something trivial to do with zsh
:
ARGV0=emacs nethack
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With