Op 25-01-20 om 02:38 schreef Harald van Dijk: > On 25/01/2020 01:13, Harald van Dijk wrote: >> On 24/01/2020 23:48, Martijn Dekker wrote: >>> There is a regression involving alias expansion, a here-document, and >>> a command substitution. The following worked fine until dash 0.5.8; >>> it throws a syntax error as of dash 0.5.9. >>> >>> alias BEGIN='{' END='}' >>> BEGIN >>> cat <>> $(echo hi) >>> eof >>> END >> >> Nice find. >> >> When the newline after cat <> indicate that the shell is in a state where aliases can be expanded. >> Then, parseheredoc() is called, which in turn calls readtoken1() to >> parse the here-document. readtoken() re-sets checkkwd once it is done, >> but readtoken1() does not, so normally this preserves the "can expand >> aliases" state. However, nested command substitutions do reset >> checkkwd, so things break. >> >> Until 0.5.8, parseheredoc() was called first, and only after that did >> checkkwd get changed. >> >> Either parseheredoc() needs to save and restore checkkwd, or the code >> calling parseheredoc() needs to ensure that it sets checkkwd as >> appropriate afterwards. Saving and restoring checkkwd in parseheredoc() seems the simplest and the most future-proof, so here's a patch to do that. > There is another place that parseheredoc() can be called from where > checkkwd was not being corrected afterwards: > >   alias BEGIN='{' END='}' >   : <   $(echo hi) >   EOF >   BEGIN >   echo ok >   END > > This has been failing for longer. The patch fixes this as well. -- modernish -- harness the shell https://github.com/modernish/modernish