notes: decide to follow regular bash behaviour, not POSIX

This commit is contained in:
Khaïs COLIN 2025-02-11 13:57:56 +01:00
parent 806e98ac97
commit 78298fbb1d
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo

View file

@ -2,7 +2,9 @@
cf. [Bash Reference Manual](https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html) cf. [Bash Reference Manual](https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html)
Comparative testing with bash should be done with bash --norc --posix. Comparative testing with bash should be done with bash --norc.
In case of difference between regular bash and posix bash, we decide to follow regular bash.
## Ideas for testing ## Ideas for testing
* use prysk or shellspec with shell=./minishell * use prysk or shellspec with shell=./minishell
@ -339,27 +341,16 @@ The word following the redirection operator, unless otherwise noted, is
subjected to parameter expansion, filename expansion, word splitting, and subjected to parameter expansion, filename expansion, word splitting, and
quote removal. quote removal.
If it expands to more than one word, Bash reports an error, except when in posix If it expands to more than one word, Bash reports an error.
mode.
TODO: decide if we follow posix default or bash default
Note: This behaviour change is, as far as I can tell, not documented in the Bash
Reference Manual.
This is the correct behaviour:
```shell ```shell
# bash behaviour
bash-5.1$ var="file1 file2" bash-5.1$ var="file1 file2"
bash-5.1$ echo "hello world" > $var bash-5.1$ echo "hello world" > $var
bash: $var: ambiguous redirect bash: $var: ambiguous redirect
# posix behaviour
bash-5.1$ var="file1 file2"
bash-5.1$ echo "hello world" > $var
bash-5.1$ cat "$var"
hello world
``` ```
In bash mode and in posix mode, if the variable is not defined, bash prints the If the variable is not defined, bash prints the following error:
following error:
```shell ```shell
bash-5.1$ echo "hello world" > $nonexist bash-5.1$ echo "hello world" > $nonexist