position variables in substring extraction use octal number recognition

Microsoft Windows
Post Reply
Martin
Posts: 1
Joined: 2022-May-11, 11:25 am

position variables in substring extraction use octal number recognition

Post by Martin »

test this:

setlocal enableDelayedExpansion

set a=0123456789@ab3de6gh9$AB3DE6GH9

echo without '0': %a:~17,8%
echo with '0': %a:~017,10%
echo with '0': %a:~017,08%

Result:
without '0': gh9$AB3D
with '0': e6gh9$AB3D
with '0': a:~017,08
bluesxman
Posts: 10
Joined: 2021-Jul-26, 3:41 pm

Re: position variables in substring extraction use octal number recognition

Post by bluesxman »

Interesting, don't remember noticing that before ... but doesn't altogether come as a surprise, given that other numeric handling interprets octal.

Code: Select all

S:\>if 8 EQU 010 echo hello octal
hello octal

S:\>set /a x=010
8
Good to know for potential gotchas though!

There is, however, an interesting divergence from this adherence

Code: Select all

S:\>octal_exit.cmd

S:\>exit /b 010

S:\>echo %ERRORLEVEL%
10
Post Reply