mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
notes: clarified note about parameter expansion in here doc
Still need to see if we have to implement that..
This commit is contained in:
parent
e6e108a98d
commit
806e98ac97
1 changed files with 49 additions and 8 deletions
57
NOTES.md
57
NOTES.md
|
|
@ -459,15 +459,56 @@ source until a line containing only word (with no trailing blanks) is seen. All
|
|||
of the lines read up to that point are then used as the standard input for a
|
||||
command.
|
||||
|
||||
TODO: The following paragraph may not apply fully to our project, check it again!
|
||||
|
||||
No parameter and variable expansion, command substitution, arithmetic expansion,
|
||||
or filename expansion is performed on word. If any part of word is quoted, the
|
||||
delimiter is the result of quote removal on word, and the lines in the
|
||||
here-document are not expanded. If word is unquoted, all lines of the
|
||||
here-document are subjected to parameter expansion, command substitution, and
|
||||
arithmetic expansion, the character sequence \newline is ignored, and ‘\’ must
|
||||
be used to quote the characters ‘\’, ‘$’, and ‘`’.
|
||||
or filename expansion is performed on word.
|
||||
|
||||
If any part of word is quoted, the delimiter is the result of quote removal on
|
||||
word, and the lines in the here-document are not expanded. If word is unquoted,
|
||||
all lines of the here-document are subjected to parameter expansion, and the
|
||||
character sequence \\newline is ignored.
|
||||
|
||||
This is the correct behaviour for quoting and parameter expansion:
|
||||
```shell
|
||||
bash-5.2$ cat << EOF
|
||||
> hello
|
||||
> $$
|
||||
> EOF
|
||||
hello
|
||||
1491742
|
||||
bash-5.2$ cat << "EOF"
|
||||
> hello
|
||||
> $$
|
||||
> EOF
|
||||
hello
|
||||
$$
|
||||
bash-5.2$ cat << 'E'OF
|
||||
> hello
|
||||
> $$
|
||||
> EOF
|
||||
hello
|
||||
$$
|
||||
bash-5.2$ cat << $USER
|
||||
> hello
|
||||
> khais
|
||||
> $USER
|
||||
hello
|
||||
khais
|
||||
bash-5.2$ echo $USER
|
||||
khais
|
||||
bash-5.2$ cat << "$USER"
|
||||
> $USER
|
||||
```
|
||||
|
||||
TODO: do we need to ignore \\newline? subject says \\ is not required..
|
||||
|
||||
If we have to implement it, this is the correct behaviour:
|
||||
```shell
|
||||
bash-5.2$ cat << EOF
|
||||
> hello \
|
||||
world
|
||||
> EOF
|
||||
hello world
|
||||
```
|
||||
|
||||
## Definitions
|
||||
cf. [Bash Reference Manual](https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Definitions)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue