Why does ksh allow unpaired quotes, but bash doesn't?

When I execute the following command, I get an error in the bash shell, but it works fine in the Korn shell. The only difference is that at the end of awk after} there is no single quote. Could you help me understand why?

echo `echo "abcd" | awk '{ print $1 }` 
+8
bash shell awk ksh
source share
1 answer

In the Korn shell, both reverse ticks and quotation marks can be left unsurpassed, the tokenizer will try to guess where it will end, and accordingly match them.

Examples:

 /home/ufierro # echo "`echo ah" + echo ah + echo ah ah /home/ufierro # echo `echo 'hello world` + echo 'hello world' + echo hello world hello world 

Note that both examples show a different case for the behavior described above. The first example shows how, during parsing, one reverse tick in double quotes was completed, and the second example shows how one quote inside the reverse ticks was completed.

+1
source share

All Articles