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: microsuxx
Subject: Re: "printf %d ''" should diagnose the empty string
Date: Mon, 10 Feb 2025 23:45:32 +0100

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

On Mon, Feb 10, 2025, 11:14 PM Phi Debian <phi.debian@gmail.com> wrote:

> On Mon, Feb 10, 2025 at 11:10 PM Greg Wooledge <greg@wooledge.org> wrote:
>
> >
> > hobbit:~$ phi 029
> > bash: ((: 029: value too great for base (error token is "029")
> > bash: ((: 029: value too great for base (error token is "029")
> >
> > So we come full circle.
> >
>
> Nope phi() is not mine and doesn't remove the error message, see my prev
> post about nuking $((....)) syntax error
>
> 029 is not a number
>
> my latest post gives
>
> $ isanum  029  && echo y || echo n
> n
>


reply via email to

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