Re: Expansion-lookalikes in heredoc delimiters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/9/18 4:51 PM, Martijn Dekker wrote:
Op 08-03-18 om 22:03 schreef Harald van Dijk:
Consider this:

   cat <<`bad`
   `bad`

As far as I can tell, this is technically valid, supposed to print
nothing, and accepted in most other shells.
[...]
This is pretty clearly a case that no serious script is ever going to
encounter, not to mention one that many shells don't even attempt to
support, at least not completely, so I don't think this is a real
problem.

How do you figure that "not many" do? By my tests, the vast majority of
shells support it completely -- much more still if you count their
respective user bases instead of counting them all equally.

ksh93 performs incorrect quote removal: when taking ${$+""} as a delimiter, it looks for literally that, rather than ${$+}.

posh and pdksh don't accept spaces, so when taking `bug bug` as a delimiter, they take the second ` as starting a command substitution.

yash rejects <<${x^} as an invalid parameter expansion, even though there's no parameter expansion here.

bash and zsh perform pretty well.

I'm mentioning it anyway because I was trying to come up with a
few more test cases for the parser, and I think it's good to have a
record not only of what worked, what has been made to work, and what got
broken, but also of what's never going to be work.

I think it should be fixed to act either like FreeBSD sh or like the
majority. Fixing obscure bugs that "no one will ever encounter" may fix
other bugs in the process, and increases the integrity of the code.

Changing dash to issue an error message could be nice.

Changing dash to support this would in my opinion be unreasonable, as it would require a total rewrite of the parser.

Cheers,
Harald van Dijk
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux