History Expansion in Arithmetic Expansion

2024-03-23 Thread A4-Tacks
Configuration Information [Automatically generated, do not change]:
Machine: aarch64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -march=armv8-a -O2 -pipe -fstack-protector-strong -fno-plt 
-fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security   
  -fstack-clash-protection 
-DDEFAULT_PATH_VALUE='/usr/local/sbin:/usr/local/bin:/usr/bin' 
-DSTANDARD_UTILS_PATH='/usr/bin' -DSYS_BASHRC='/etc/bash.bashrc' 
-DSYS_BASH_LOGOUT='/etc/bash.bash_logout' -DNON_INTERACTIVE_LOGIN_SHELLS
uname output: Linux localhost 4.14.116 #1 SMP PREEMPT Tue Mar 22 15:13:10 CST 
2022 aarch64 GNU/Linux
Machine Type: aarch64-unknown-linux-gnu

Bash Version: 5.2
Patch Level: 26
Release Status: release

Description:
 I am unable to use logical inversion operators in line
 arithmetic extensions, nor can I escape them, which is undoubtedly abnormal

Repeat-By:
 ```bash
 $ ((!RANDOM))
 bash: !RANDOM: event not found
 ```





Re: History Expansion in Arithmetic Expansion

2024-03-23 Thread alex xmb sw ratchev
On Sat, Mar 23, 2024, 16:34 A4-Tacks  wrote:

> Configuration Information [Automatically generated, do not change]:
> Machine: aarch64
> OS: linux-gnu
> Compiler: gcc
> Compilation CFLAGS: -march=armv8-a -O2 -pipe -fstack-protector-strong
> -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat
> -Werror=format-security -fstack-clash-protection
> -DDEFAULT_PATH_VALUE='/usr/local/sbin:/usr/local/bin:/usr/bin'
> -DSTANDARD_UTILS_PATH='/usr/bin' -DSYS_BASHRC='/etc/bash.bashrc'
> -DSYS_BASH_LOGOUT='/etc/bash.bash_logout' -DNON_INTERACTIVE_LOGIN_SHELLS
> uname output: Linux localhost 4.14.116 #1 SMP PREEMPT Tue Mar 22 15:13:10
> CST 2022 aarch64 GNU/Linux
> Machine Type: aarch64-unknown-linux-gnu
>
> Bash Version: 5.2
> Patch Level: 26
> Release Status: release
>
> Description:
>  I am unable to use logical inversion operators in line
>  arithmetic extensions, nor can I escape them, which is undoubtedly
> abnormal
>
> Repeat-By:
>  ```bash
>  $ ((!RANDOM))
>  bash: !RANDOM: event not found
>  ```
>

small workaround

(( ! bla ))

>


Re: History Expansion in Arithmetic Expansion

2024-03-23 Thread A4-Tacks
Thank you, this is very effective!



 Replied Message 
| From | alex xmb sw ratchev |
| Date | 03/23/2024 23:38 |
| To | A4-Tacks |
| Cc | bug-bash |
| Subject | Re: History Expansion in Arithmetic Expansion |



On Sat, Mar 23, 2024, 16:34 A4-Tacks  wrote:

Configuration Information [Automatically generated, do not change]:
Machine: aarch64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -march=armv8-a -O2 -pipe -fstack-protector-strong -fno-plt 
-fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security   
  -fstack-clash-protection 
-DDEFAULT_PATH_VALUE='/usr/local/sbin:/usr/local/bin:/usr/bin' 
-DSTANDARD_UTILS_PATH='/usr/bin' -DSYS_BASHRC='/etc/bash.bashrc' 
-DSYS_BASH_LOGOUT='/etc/bash.bash_logout' -DNON_INTERACTIVE_LOGIN_SHELLS
uname output: Linux localhost 4.14.116 #1 SMP PREEMPT Tue Mar 22 15:13:10 CST 
2022 aarch64 GNU/Linux
Machine Type: aarch64-unknown-linux-gnu

Bash Version: 5.2
Patch Level: 26
Release Status: release

Description:
 I am unable to use logical inversion operators in line
 arithmetic extensions, nor can I escape them, which is undoubtedly abnormal

Repeat-By:
 ```bash
 $ ((!RANDOM))
 bash: !RANDOM: event not found
 ```



small workaround


(( ! bla ))

Re: History Expansion in Arithmetic Expansion

2024-03-23 Thread Lawrence Velázquez
On Sat, Mar 23, 2024, at 11:34 AM, A4-Tacks wrote:
> Description:
>  I am unable to use logical inversion operators in line
>  arithmetic extensions, nor can I escape them, which is undoubtedly 
> abnormal
>
> Repeat-By:
>  ```bash
>  $ ((!RANDOM))
>  bash: !RANDOM: event not found
>  ```

Unfortunately this is intentional and documented.  In interactive
shells with default settings, unquoted `!' introduces a history
expansion [1].  You cannot backslash-escape `!' within `((exp))'
because `exp' is treated almost [*] as if it were double-quoted,
and within double quotes `\' escapes `!' but is not removed [3].

[1]: https://www.gnu.org/software/bash/manual/html_node/History-Interaction.html
[2]: 
https://www.gnu.org/software/bash/manual/html_node/Conditional-Constructs.html
[3]: https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html

[*]: One exception is that double quotes themselves are removed,
so another (arguably worse) workaround is `(("!"RANDOM))'.

-- 
vq



Add option to just print history, with no added timestamps or line numbers

2024-03-23 Thread Dan Jacobson
$ help history
should mention how in the world one is supposed to just print the plain history,
without any line numbers or time stamps.

You might say, "Just strip it off with perl or sed." Well, fine. Then mention 
that in help history.

Currently one needs massive superfund environmental clean-up effort 
workarounds, e.g.,
$ HISTTIMEFORMAT=' ' history | perl -pwle 's/^\s+\S+\s+//'

Better yet, add a
history -j: Just print history, with no added timestamps or line numbers, etc.

Or OK, there's HISTTIMEFORMAT. How about also a HISTFORMAT (default " %5n %t 
%h\n" or whatever,) so one could use "%h\n" for "just give me the history item."



Re: Add option to just print history, with no added timestamps or line numbers

2024-03-23 Thread Lawrence Velázquez
On Sun, Mar 24, 2024, at 1:40 AM, Dan Jacobson wrote:
> $ help history
> should mention how in the world one is supposed to just print the plain 
> history,
> without any line numbers or time stamps.

fc -ln 1

-- 
vq