[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ! history expansion occurs within arithmetic substitutions
From: |
Dale R. Worley |
Subject: |
Re: ! history expansion occurs within arithmetic substitutions |
Date: |
Tue, 08 Aug 2023 15:11:22 -0400 |
Zachary Santer <zsanter@gmail.com> writes:
> Description:
> Similarly, history expansion occurs within arithmetic substitutions. This
> will never, ever be what the user wants. And now I know how to make it not
> happen.
>
> Repeat-By:
> $ set +o histexpand
Well, yes, if you turn off history expansion, then it won't occur within
arithmetic substitutions.
But I would not take it as given that nobody would ever want to use
history expanstion within an arithmetic substitution. Let me concoct an
example:
$ i=4
$ echo (( i+1 ))
bash: syntax error near unexpected token `('
$ echo $(( !:3 ))
echo $(( i+1 ))
5
$
(This would be more likely if "i+1" was a much more complicated
expression.)
But it seems to me that the way to avoid this is to always put a space
after "!" in arithmetic expressions. "!" followed by space is never
subject to history expansion.
More troublesome, I think, are several variable substitutions which
include "!" followed by a name. But I doubt they're used much in
interactive mode.
Dale
- !; 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, 2023/08/08
- Re: ! history expansion occurs within arithmetic substitutions,
Dale R. Worley <=
- 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