bug-bash
[Top][All Lists]
Advanced

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

Re: Suggested BASH Improvement


From: Chet Ramey
Subject: Re: Suggested BASH Improvement
Date: Wed, 18 Sep 2024 10:51:51 -0400
User-agent: Mozilla Thunderbird

On 9/17/24 7:50 PM, BRUCE FOWLER via Bug reports for the GNU Bourne Again SHell wrote:
An interesting problem I ran into recently:
I have a shell script that I run about once a month that
"screen-scrapes" from the output of another program using the
substring capability, e.g. ${data_line:12:2}. This is pulling
out the two-digit month ranging from "01" to "12".
This worked fine, even giving the right answers, for
months earlier in the year. Then came August, and it went
sideways because the leading "0" was forcing the number to be
interpreted as octal. My first reaction was, What's going on,
this has run just fine for months. The second reaction was,
WTF, who uses octal anymore? But I understand it is because
of C-language compatibility. I could use the [base#]n form
but that gets awkward.

Thanks for the proposal. I think the [base#]n syntax is reasonable
here without adding a new shell option.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

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