bug-bash
[Top][All Lists]
Advanced

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

Re: ! history expansion occurs within arithmetic substitutions


From: Martin D Kealey
Subject: Re: ! history expansion occurs within arithmetic substitutions
Date: Wed, 9 Aug 2023 04:59:35 +1000

On Tue, 8 Aug 2023, 23:24 Zachary Santer, <zsanter@gmail.com> wrote:

> Description:
> Similarly, history expansion occurs within arithmetic substitutions. This
> will never, ever be what the user wants.


Correction: it will never ever be what YOU want.
I can certainly think of uses for history expansion in arithmetic context,
for example (imagine this done with much bigger numbers):

$ coprimepairs 7 9 32 48
7 9
7 32
9 32
$ echo $(( !:2 * !:3 ))
echo $(( 9 * 32 ))
288
$

If anyone wants to avoid such history expansion, that's easy: always put
spaces around operators in arithmetic context.

I would recommend turning on histreedit, so that it's less cumbersome to
fix any unexpected history expansions.

$ echo $(( ! 0 ))
1
$

Please don't go breaking existing functionality just because someone can't
imagine a use for it.

-Martin


reply via email to

[Prev in Thread] Current Thread [Next in Thread]