Re: dash tested against ash testsuite: 17 failures

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

 



On 3/6/18 9:45 AM, Herbert Xu wrote:
On Wed, Oct 12, 2016 at 07:24:26PM +0200, Harald van Dijk wrote:

I would have expected another exception to be in alias expansions that
end in a backslash. Shells are not entirely in agreement there, but most
appear to treat this the regular way, meaning

   dash -c 'alias bs=\\
   bs
   '

prints nothing.

I think your patch changes this.  In order to preserve the existing
behaviour (which seems logical), you should change the second pgetc
call in pgetc_eatbnl to pgetc2.

Oh, indeed, thanks.

There's another problem: when there is no following command (as in the above example), things break. A shorter reproducer that has failed for years is

  $ dash -c 'alias x=
  x'
  dash: 2: Syntax error: end of file unexpected

This breaks because the part where list() checks for NL/EOF, checkkwd==0, so aliases aren't expanded. Immediately after that, checkkwd is set and the next call to readtoken() would return TEOF, but by that point, dash has already committed to parsing a command.

Since this is actually a long-standing problem, not something introduced by the patch, I think it's okay to ignore for now. Do you agree?

With more extensive testing, the only issue I've seen is what Jilles
Tjoelker had already mentioned, namely that backslash-newline should be
preserved inside single-quoted strings, and also that it should be
preserved inside heredocs where any part of the delimiter is quoted:

    cat <<\EOF
    \
    EOF

dash's parsing treats this mostly the same as a single-quoted string,
and the same extra check handles both cases.

Here's an updated patch. Hoping this looks okay and can be applied.


I'm fine with the concept.  However, your patch also breaks here-
document parsing when the delimiter is a single backslash.

	cat << "\"
	\
>
If you can fix these two problems it should be good to go.

As Martijn Dekker wrote, this should work when the backslash is escaped or single-quoted, and in my testing does. But what you have is a nice start of another corner case:

  cat << "\"
  \
  "EOF
  ok
  "
  EOF

I'm happily surprised to see that dash accepts and gives sensible treatment to multi-line heredoc delimiters.

Okay with your one extra pgetc()=>pgetc2() change, then?

Cheers,
Harald van Dijk

Cheers,
--
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