From 78298fbb1d3f9226a689e3917af143d283528cb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kha=C3=AFs=20COLIN?= Date: Tue, 11 Feb 2025 13:57:56 +0100 Subject: [PATCH] notes: decide to follow regular bash behaviour, not POSIX --- NOTES.md | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/NOTES.md b/NOTES.md index 22e5d3a..3b654b8 100644 --- a/NOTES.md +++ b/NOTES.md @@ -2,7 +2,9 @@ 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 * 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 quote removal. -If it expands to more than one word, Bash reports an error, except when in posix -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. +If it expands to more than one word, Bash reports an error. +This is the correct behaviour: ```shell -# bash behaviour bash-5.1$ var="file1 file2" bash-5.1$ echo "hello world" > $var 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 -following error: +If the variable is not defined, bash prints the following error: ```shell bash-5.1$ echo "hello world" > $nonexist