On Mon, Nov 16, 2020 at 11:04 PM Bodie <bo...@bodie.cz> wrote: > On 17.11.2020 05:04, Jordan Geoghegan wrote: > > 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. > > > > What exactly are you trying to achieve? > > If you will look in sh(1) for 'Command expansion' then there are defined > rules and your form is not between them. >
I disagree. I believe this: cat <<'__EOT' # I'll choose not to close this quote other_stuff __EOT matches the syntax for 'command'...once you take into account redirections, including 'here-docs'. Or do you believe that's not a valid command on it's own? To put another way, I agree with halex@ that this is a (known, not yet fixed) bug. So error message about missing closing quote is actually proper > behavior. > Nope. This is a bug in OpenBSD ksh. > As well it is good idea to avoid reserved words as a names for variables > ;-) > (test............) Hmm? * 'test' is not a reserved word in the shell * shell variable names are a completely different namespace than shell reserved words or commands * code written to check whether something is a bug is 1000% out-of-bounds for style comments: either there's a bug or there isn't Philip Guenther