[PATCH] printf width/precision argument overflow

2023-10-19 Thread Grisha Levit
When reading a printf width/precision argument, the value isn't checked for overflow if it happens to be the last argument: $ INT_MAX=$(getconf INT_MAX) $ printf '[%*s]' "$((INT_MAX+1))" [] $ printf '[%*s]' "$((INT_MAX+1))" X -bash: printf: X: Result too large [] ..and the

Re: using a variable from global scope or checking whether it is local to some scope

2023-10-19 Thread ikhxcsz7y xmbott
On Thu, Oct 19, 2023, 23:42 Christoph Anton Mitterer wrote: > Hey Alex. > > On Thu, 2023-10-19 at 22:17 +0200, alex xmb sw ratchev wrote: > > another answer > > in ur code , force global / local whenever u need it > > > > ~ $ ( declare -g a ; a=2 ; declare -p a ; declare a ; declare -p a ; > > a=

[PATCH] printf %ls/%lc/%Q fixes

2023-10-19 Thread Grisha Levit
A few issues with handling of the new %ls, %lc and %Q conversion specifications: The %ls and %lc conversion specifications dereference a null pointer if used without an argument: $ (printf %ls) Segmentation fault: 11 $ (printf %lc) Segmentation fault: 11 The Q conversion specifie

Re: wrong variable name in error message about unbound variable?

2023-10-19 Thread alex xmb sw ratchev
On Thu, Oct 19, 2023, 16:58 Chet Ramey wrote: > On 10/17/23 3:32 PM, Grisha Levit wrote: > > > The reason is that if there was no variable found prior to expanding > > the subscript, bash does not check to see if one was created during > > that process. > > Thanks, I'll consider it. Behavior vari

Re: bash tries to parse comsub in quoted PE pattern

2023-10-19 Thread Chet Ramey
On 10/18/23 1:08 PM, Emanuele Torre wrote: On Wed, Oct 18, 2023 at 11:24:11AM -0400, Chet Ramey wrote: On 10/18/23 10:50 AM, Chet Ramey wrote: Is it really ok to break that behaviour? That's why, if you want the first problem repaired, you have to specify which word expansions are ok to pars

Re: wrong variable name in error message about unbound variable?

2023-10-19 Thread Chet Ramey
On 10/17/23 3:32 PM, Grisha Levit wrote: The reason is that if there was no variable found prior to expanding the subscript, bash does not check to see if one was created during that process. Thanks, I'll consider it. Behavior varies across shells in this area. Chet -- ``The lyf so short, th