minishell icon indicating copy to clipboard operation
minishell copied to clipboard

[DECISION] Assignments preceding a command are only applied for the duration of the command following it - with exceptions

Open itislu opened this issue 1 year ago • 1 comments

We need to decide what parts of normal assignment we want to implement, if any.

Example:

bash-5.1$ HOME=/ cd
bash-5.1$ pwd
/
bash-5.1$ echo $HOME
/nfs/homes/ldulling

Exceptions are "special builtins" in POSIX mode:

  • export
  • exit
  • unset

For these commands, the assignments are not just local to the command, but to the whole shell.

itislu avatar Feb 09 '24 20:02 itislu

I now have the opinion that it's fine to treat our builtins like normal, non-POSIX bash does it. All the POSIX special builtins are commands that seem to handle things that any programming language has built-in. For these I think it makes sense that, if you do an assignment before f.e. return, you want the assignment to stay.

However, since we don't implement shell scripts, there's really no need to make those 3 builtins that would be affected in a special way.

itislu avatar Jul 17 '24 16:07 itislu