Re: The "leading zero means octal" thing...

Liste des GroupesRevenir à cu shell 
Sujet : Re: The "leading zero means octal" thing...
De : janis_papanagnou+ng (at) *nospam* hotmail.com (Janis Papanagnou)
Groupes : comp.lang.tcl comp.unix.shell comp.editors
Date : 04. Jan 2025, 23:54:15
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vlce6p$lk3q$1@dont-email.me>
References : 1
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
On 04.01.2025 23:14, Kenny McCormack wrote:
First of all, yes, I know this is all standardized and it is based on
legacy C conventions and it can't be changed and so on and so forth.
 
But if not a bug, it is certainly a misfeature.
 
I am referring, of course, to the convention that a number with a leading
zero is interpreted as octal.  I can't count the number of times I've been
bitten by this - in various languages/environments all across the Unix
ecosystem.  Note the choice of newsgroups above - I have been affected by
this in each of these environments - most recently in Tcl (Expect) and in
the VIM editor.
 
In fact, the really obnoxious part about it is that it means a number
string like "08" is invalid, because 8 is not a valid digit in octal.  I
wish there was a global way to turn this off - some option to set that says
"Don't do that!".  I realize, of course, that it has to be on by default,
but it should be possible to turn it off.
 
Incidentally, and this was my motivation for posting this rant, I hit this
in VIM - where if the cursor is sitting on the zero in a string like Foo07
and you hit ^A, it changes it to - are you ready? - not Foo08, but Foo010.
 
Totally weird and unexpected.

Yes.

(You can find this complaint also already mentioned on the Web
in 2012, maybe even before. I suppose it's hard to do or change
anything as default behavior now.)

As a consequence, in Kornshell, I'm using a number prefix 10# to
counter that misbehavior. (I'd suppose this works also in other
major shells like Bash.)

In Vim there's a "sensible.vim" plugin available. (But I've not
tried it.) Given the tons of options in Vim I wonder why they
haven't supported an option to fix it inherently.

Janis


Date Sujet#  Auteur
4 Jan 25 * The "leading zero means octal" thing...14Kenny McCormack
4 Jan 25 +* Re: The "leading zero means octal" thing...2Janis Papanagnou
5 Jan 25 i`- Re: The "leading zero means octal" thing...1Kenny McCormack
5 Jan 25 +* Re: The "leading zero means octal" thing...2Rich
5 Jan 25 i`- Re: The "leading zero means octal" thing...1Kenny McCormack
5 Jan 25 +* Re: The "leading zero means octal" thing...5Eli the Bearded
5 Jan 25 i`* Re: The "leading zero means octal" thing...4Kenny McCormack
5 Jan 25 i `* Re: The "leading zero means octal" thing...3Kenny McCormack
5 Jan 25 i  +- 'nf' in VIM (Was: The "leading zero means octal" thing...)1Kenny McCormack
5 Jan 25 i  `- Re: The "leading zero means octal" thing...1Janis Papanagnou
5 Jan 25 +- Re: The "leading zero means octal" thing...1Joe Makowiec
5 Jan 25 +* Re: The "leading zero means octal" thing...2saito
5 Jan 25 i`- Re: The "leading zero means octal" thing...1Kenny McCormack
6 Jan 25 `- Re: The "leading zero means octal" thing...1Eric Pozharski

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal