simonmichael / shelltestrunner

Easy, repeatable testing of CLI programs/commands
GNU General Public License v3.0
130 stars 10 forks source link

Different output with different bash versions #35

Closed asr closed 2 months ago

asr commented 2 months ago

Using Ubuntu 22.04.4 LTS and GNU bash version 5.1.16 the following test works running shelltest with the option --shell=bash:

$ echo (
>2
bash: -c: line 1: syntax error near unexpected token `newline'
bash: -c: line 1: `echo ('
>= 2

but using Ubuntu 20.04.6 LTS and GNU bash version 5.0.17 I need to replace line 1 by line 0 and >=2 by >=1:

$ echo (
>2
bash: -c: line 0: syntax error near unexpected token `newline'
bash: -c: line 0: `echo ('
>= 1

Any ideas why I'm getting different outputs? I'm using shelltest 1.10 compiled with GHC 9.10.1.

simonmichael commented 2 months ago

Hi @asr, I think you'd have to ask eg #bash IRC channel; it looks like a change in bash. I get slightly different behaviour when comparing bash 3.2 and 5.2 on mac (both produce exit code 2 for me):

$ /bin/bash --version
GNU bash, version 3.2.57(1)-release (arm64-apple-darwin23)

$ /opt/homebrew/bin/bash --version
GNU bash, version 5.2.21(1)-release (aarch64-apple-darwin23.0.0)

$ /bin/bash -c 'echo ('; echo $?
/bin/bash: -c: line 0: syntax error near unexpected token `newline'
/bin/bash: -c: line 0: `echo ('
2

$ /opt/homebrew/bin/bash -c 'echo ('; echo $?
/opt/homebrew/bin/bash: -c: line 1: syntax error near unexpected token `newline'
/opt/homebrew/bin/bash: -c: line 1: `echo ('
2
asr commented 2 months ago

Thanks @simonmichael.