bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "printf %d ''" should diagnose the empty string


From: Phi Debian
Subject: Re: "printf %d ''" should diagnose the empty string
Date: Tue, 11 Feb 2025 07:14:30 +0100

On Mon, Feb 10, 2025 at 11:46 PM microsuxx <fxmbsw7@gmail.com> wrote:

> a bit unrelated .. cheap numbers filter ..
>
> gimme_num( ) { declare -n b=BASH_REMATCH\[1] ; local o m=[0-9,.] s=$n i t ;
> t="(-?$m+)" ; unset -v o ; for n ; do unset -v i ; while [[ $n =~ $t ]] ;
> do n=${n/"$b"} i= o+=$b$s ; done ; [[ -v i ]] && o+=$s ; done ; [[ -v o ]]
> && printf %s "$o" ; }
>
> gimme_num ' ab3.44 cd---.99 ' cd cd 77.7.77
>
> 3.44
> -.99
>
> 77.7.77
>
>
Rejected
$ gimme_num '0x10'
 0x10xx
$ gimme_num '64#yo'
64xx
$ gimme_num '0x10'
0#yo10#yo#yo

gimme_num should be renamed random_string()


reply via email to

[Prev in Thread] Current Thread [Next in Thread]