Monday, November 16, 2020

Potential ksh bug?

Hello,

I'm not sure if this is a bug, or if it's just a pdksh thing, but I
stumbled upon some interesting behaviour when I was tinkering around
with quoting and using a poor mans array:

test=$(cat <<'__EOT'
# I'll choose not to close this quote
other_stuff
__EOT
)

echo "$test"


When I run this command on ash, dash, yash, bash, zsh or ksh93 I get the
following output:

# I'll choose not to close this quote
other_stuff

But when I run it on ksh from base or any pdksh derivative it throws an
error about an unclosed quote:

test.sh[8]: no closing quote

This snippet works on every POSIX-y shell in the ports tree, and fails
on every pdksh variant I tried, including on NetBSD and DragonflyBSD as
well.  I don't have the requisite esoteric knowledge regarding pdksh's
internal quoting logic, so I'm hoping one of the gurus here can
determine whether this is a bug or if I'm just doing something annoying.

Any insight that can be provided would be much appreciated.

Regards,

Jordan

No comments:

Post a Comment