On Mon, Feb 10, 2025 at 11:48 AM Chet Ramey <chet.ra...@case.edu> wrote:
>
> On 2/10/25 11:34 AM, Zachary Santer wrote:
> > On Mon, Feb 10, 2025 at 9:20 AM Phi Debian <phi.deb...@gmail.com> wrote:
> >>
> >> If 'best *general*' refer to the shortest line noise does
> >>
> >> $((${i/?([-+])/&10#}))
> >>
> >> Qualify for better than best ? :-)
> >
> > And then this isn't even half as good:
>
> There isn't a reward for brevity or obfuscation; say what you mean:
>
> isnum2()
> {
>         case "$1" in
>         [-+] | '')      return 1;;      # empty or bare `-' or `+'
>         [-+]*[!0-9]*)   return 1;;      # non-digit with leading sign
>         [-+]*)          return 0;;      # OK
>         *[!0-9]*)       return 1;;      # non-digit
>         *)              return 0;;      # OK
>         esac
> }
>
> It obviously doesn't handle 0x constants, but could be changed to.

I question whether that's less obfuscated than mine, but it definitely
doesn't remove leading zeros from the variable for easier use
elsewhere in the script.

Reply via email to