sh
sh copied to clipboard
interp: misplaced quote when printing while loop
Using the script below as file input:
$ cat while.sh
#!/bin/bash
set -ex
x=1
while [ $x -le 5 ]
do
echo "Welcome $x times"
x=$(( $x + 1 ))
done
$ ./gosh while.sh &> gosh.output
$ ./while.sh &> bash.output
The problematic line from the gosh's output is the misplaced quotes when printing the while expression:
$ diff -y --suppress-common-lines bash.output gosh.output
+ '[' 1 -le 5 ']' | + [ '1 -le 5 ]'
+ '[' 2 -le 5 ']' | + [ '2 -le 5 ]'
+ '[' 3 -le 5 ']' | + [ '3 -le 5 ]'
+ '[' 4 -le 5 ']' | + [ '4 -le 5 ]'
+ '[' 5 -le 5 ']' | + [ '5 -le 5 ]'
+ '[' 6 -le 5 ']' | + [ '6 -le 5 ]'