Re: Arithmetic expression: interest in unsigned right shift?

2022-07-16 Thread Martin D Kealey
Printf %u already reveals the word size, as do most kinds of overflow - albeit messily, like $((3**40)) At least by explicitly exposing the word size in a controlled manner, we can write code that avoids unintended overflow. -Martin On Sun, 17 Jul 2022, 11:54 Dale R. Worley, wrote: > Steffen

Re: Arithmetic expression: interest in unsigned right shift?

2022-07-16 Thread Martin D Kealey
Hi Steffen, thanks for that. It will be especially useful for defining (( MAXINT = ~0 >>> 1 )). This reminds me of some other operations I've been meaning to implement, including true modulus +% (where the sign of the result always matches the divisor) with the corresponding flooring division +/

Re: local -r issue in conjunction with trap

2022-07-16 Thread Dale R. Worley
Robert Stoll writes: > test1 # works as exit happens outside of test1 > test2 # fails with ./src/test.sh: line 6: local: readonlyVar: readonly > variable Beware that you haven't specified what you mean by "works" and "fails". I assume from the context that "fails" means "produces an error messag

Re: Gettings LINES and COLUMNS from stderr instead of /dev/tty

2022-07-16 Thread Dale R. Worley
Martin Schulte writes: > I'm just wondering that bash (reproduced with 5.2-rc1 under Debian 11) > seems to determine LINES and COLUMNS from stderr. It's not clear to me that the manual page says where the LINES and COLUMNS values are obtained from. Dale

Re: Arithmetic expression: interest in unsigned right shift?

2022-07-16 Thread Dale R. Worley
Steffen Nurpmeso writes: > I realized there is no unsigned right shift in bash arithmetic > expression, and thought maybe there is interest. This would be difficult to define cleanly. Currently, arithmetic values are considered to be signed, and >> operates on them as such. So $ echo $(( 1

Arithmetic expression: interest in unsigned right shift?

2022-07-16 Thread Steffen Nurpmeso
Hello. I realized there is no unsigned right shift in bash arithmetic expression, and thought maybe there is interest. This is a not even compile-tested diff against 5.1.16. (Using same tab/space as in surroundings.) A nice Sunday i wish everyone. diff -Napru bash-5.1.orig/expr.c bash-5.1/expr.c

Gettings LINES and COLUMNS from stderr instead of /dev/tty

2022-07-16 Thread Martin Schulte
Hello, I'm just wondering that bash (reproduced with 5.2-rc1 under Debian 11) seems to determine LINES and COLUMNS from stderr. For example, this will lead to strange results when starting the script #!/bin/bash shopt -s checkwinsize trap 'echo $LINES $COLUMNS' SIGWINCH while true; do sleep 0.

Re: local -r issue in conjunction with trap

2022-07-16 Thread Robert Elz
Date:Fri, 15 Jul 2022 16:13:40 + (UTC) From:Robert Stoll Message-ID: <1549965963.26496.1657901620717.javamail.zim...@tegonal.com> | Unfortunately I have never built bash on my own and it would probably | take me too much time to do it. It probably wouldn't, f