mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-05 23:18:08 +01:00
notes: add an interesting case of shell variables vs environment variables
This commit is contained in:
parent
f3c875c34e
commit
9c81ac832a
1 changed files with 11 additions and 0 deletions
11
NOTES.md
11
NOTES.md
|
|
@ -213,6 +213,17 @@ The form is $VAR, where VAR may only contain the following characters:
|
|||
* _
|
||||
* 0-9 (not in the first character)
|
||||
|
||||
Just noticed an interesting case:
|
||||
```shell
|
||||
bash-5.2$ VAR=hello # we set a shell variable (NOT environment variable)
|
||||
bash-5.2$ VAR=hi env | grep VAR=; env | grep VAR= # here VAR is an environment variable, which is only valid for the next command (the second env returns nothing, confirming that it is not valid for that command)
|
||||
VAR=hi
|
||||
bash-5.2$ env | grep VAR= # var is not an environment variable
|
||||
bash-5.2$ echo $VAR # but it is a shell variable
|
||||
hello
|
||||
```
|
||||
Luckily for us, we don't have to handle shell variables, nor do we have to handle `VAR=value` or `VAR=value cmd`.
|
||||
|
||||
#### Word Splitting
|
||||
cf. 3.5.7 Word Splitting
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue