Subject: Re: bug#36103: 24.5; Blank spaces around parentheses in history expansion in shell mode

From: Noam Postavsky <[email-masked]>
Date: Wed, 05 Jun 2019 21:02:33 -0400

merge 36103 8027
quit

Enric Rodríguez Carbonell <[email-masked]> writes:

> $ for file in $(ls); do echo $file; done

> $ !for

> M-x comint-replace-by-expanded-history

> $ for file in $ ( ls ) ; do echo $file ; done
>
> The blank spaces around the parentheses should not be there.
> Because of these blank spaces, this command cannot be executed,
> as "$ (" should be "$(".

Yes, the problem is in comint-arguments which attempts to parse a shell
line into separate arguments, using just a bunch of regexps.  This is
doomed to failure I think.  But the alternative would be a full blown
shell parser, so I don't know how feasible it will be to fix this bug.
It's been with us a long time.