minishell icon indicating copy to clipboard operation
minishell copied to clipboard

[BUG] `_` environment variable should not get created nor printed by export

Open itislu opened this issue 1 year ago • 0 comments

export should ignore the _ (single underscore) env variable that can get inherited from the previous shell.

  • [ ] Just export should not print an entry for _.
  • [ ] Trying to create a variable like this _=abc should do nothing.

In bash, this variable always gets updated with the last argument to the previous simple command, after expansion. And for the executed commands, this variable gets prepared with the full pathname of the command to be executed. https://www.gnu.org/savannah-checkouts/gnu/bash/manual/html_node/Bash-Variables.html

To see the behavior, test with declare | grep _=.

itislu avatar Feb 14 '24 16:02 itislu