minishell icon indicating copy to clipboard operation
minishell copied to clipboard

[QUESTION] Is `+=` part of the subject?

Open itislu opened this issue 1 year ago • 2 comments

This matters for both export and for local variable assignment.

If a += is specified instead of an = in shell variable assignments or in arguments to export, the previous value (if it existed) should not be replaced with the new value. Instead, the new value should be appended to the old value.

In the context where an assignment statement is assigning a value to a shell variable or array index (see Arrays), the ‘+=’ operator can be used to append to or add to the variable’s previous value.

Bash manual


It should not be too difficult to add this feature, but ofc it touches almost everything, starting from the Lexer and going all the way to the final_cmd_table and export.

itislu avatar Feb 09 '24 20:02 itislu

I think that it actually is, at least for export.

The Subject:

Your shell must implement the following builtins:

  • export with no options

+= is not an option to export, it is part of the normal arguments.

itislu avatar Feb 09 '24 20:02 itislu

But I dont want to implement all of features XD I dont think it is worth to investment the time and I wont fail anyone with this

LeaYeh avatar Feb 16 '24 16:02 LeaYeh