[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
- !; is interpreted as an history expansion that can never match anything, Emanuele Torre, 2023/08/08
- ! history expansion occurs within arithmetic substitutions, Zachary Santer, 2023/08/08
- Re: ! history expansion occurs within arithmetic substitutions, Emanuele Torre, 2023/08/08
- Re: ! history expansion occurs within arithmetic substitutions,
Martin D Kealey <=
- Re: ! history expansion occurs within arithmetic substitutions, Dale R. Worley, 2023/08/08
- Re: ! history expansion occurs within arithmetic substitutions, Andreas Schwab, 2023/08/08
- Re: ! history expansion occurs within arithmetic substitutions, Dale R. Worley, 2023/08/11
- Re: ! history expansion occurs within arithmetic substitutions, Martin D Kealey, 2023/08/11
- Re: ! history expansion occurs within arithmetic substitutions, Chet Ramey, 2023/08/14
- Re: ! history expansion occurs within arithmetic substitutions, Martin D Kealey, 2023/08/15
- Re: ! history expansion occurs within arithmetic substitutions, Zachary Santer, 2023/08/08
- Re: ! history expansion occurs within arithmetic substitutions, Dale R. Worley, 2023/08/10
- Re: ! history expansion occurs within arithmetic substitutions, Lawrence Velázquez, 2023/08/10
Re: !; is interpreted as an history expansion that can never match anything, Dale R. Worley, 2023/08/08