Some undocumented things with turned off command extensions
Moderator: DosItHelp
Some undocumented things with turned off command extensions
these variables are not accessible - CMDCMDLINE , TIME , DATE , RANDOM , ERRORLEVEL , CMDEXTVERSION , CD (but __CD__ is still there)
COLOR command is not working.
COLOR command is not working.
Last edited by npocmaka_ on 11 Feb 2017 09:42, edited 1 time in total.
Re: Some undocumented things with turned of command extensions
The following is not undocumented - but the documentation is just wrong (at least the german version).
The setlocal always accepts the command line arguments (even if extensions are disabled):
- "enableExtensions" and
- "enableDelayedExpansion".
penpen
The setlocal always accepts the command line arguments (even if extensions are disabled):
- "enableExtensions" and
- "enableDelayedExpansion".
penpen
Re: Some undocumented things with turned of command extensions
It's interesting that the color command doesn't work
As to the dynamic variables - actually it's documented behavior. Have a look at the help message of SET. The explanation of these variables begins with "If Command Extensions are enabled ...".
http://www.dostips.com/DosCommandIndex.php#SET
Steffen
As to the dynamic variables - actually it's documented behavior. Have a look at the help message of SET. The explanation of these variables begins with "If Command Extensions are enabled ...".
http://www.dostips.com/DosCommandIndex.php#SET
Steffen
Re: Some undocumented things with turned of command extensions
aGerman wrote:As to the dynamic variables - actually it's documented behavior. Have a look at the help message of SET. The explanation of these variables begins with "If Command Extensions are enabled ...".
http://www.dostips.com/DosCommandIndex.php#SET
Steffen
I should read the documentation more carefully.
Though for the color I've found nothing.
Re: Some undocumented things with turned off command extensions
COLOR, ASSOC and FTYPE are associated to command extensions but are not documented as dependent on them.
Re: Some undocumented things with turned off command extensions
mcnd wrote:COLOR, ASSOC and FTYPE are associated to command extensions but are not documented as dependent on them.
So assoc and ftype will not work also?
EDIT
Just tried. They are not working. Thanks for the info.
-
- Posts: 231
- Joined: 01 Oct 2012 13:32
- Location: Ireland
- Contact:
Re: Some undocumented things with turned off command extensions
Hello All!
Interesting discussion. I’d like to add the following observations made while extensions were disabled.
The PROMPT command doesn’t work. Neither does:
Otoh…
does work.
And another thing I’ve noticed is that if there are 2 labels with the same name, GOTO will jump to the 2nd label. Yet another example of CMD’s eccentric behaviour.
BFN!
- SB
Interesting discussion. I’d like to add the following observations made while extensions were disabled.
The PROMPT command doesn’t work. Neither does:
Code: Select all
set "prompt=@"
Otoh…
Code: Select all
set prompt=@
does work.
And another thing I’ve noticed is that if there are 2 labels with the same name, GOTO will jump to the 2nd label. Yet another example of CMD’s eccentric behaviour.
BFN!
- SB
Re: Some undocumented things with turned off command extensions
Code: Select all
set "prompt=something"
Fails as the extended SET-syntax is no longer valid in the disbaled extension context.
I can't reproduce your goto :label problem.
I can't believe it, as any goto normally starts a search from the current file position to the first matching label.
Code: Select all
@echo off
setlocal DisableExtensions
goto :myLabel
:myLabel
echo First
goto :eof
:myLabel
echo Second
goto :eof
:eof
This outputs, as expected, "First".
Btw. You need to define the :eof label, as it doesn't exists without extensions.
Curious is the error message of "exit /b" in this context.
Free translation from german wrote:The label - :EOF can't be found
Re: Some undocumented things with turned off command extensions
jeb wrote:
Btw. You need to define the :eof label, as it doesn't exists without extensions.
Curious is the error message of "exit /b" in this context.Free translation from german wrote:The label - :EOF can't be found
So exit uses goto to find the end of the file?
Should this mean that goto :eof works faster than exit /b ?
Re: Some undocumented things with turned off command extensions
npocmaka_ wrote:Should this mean that goto :eof works faster than exit /b ?
Most likely. Since you can pass a return value to exit /b the cmd has to evaluate a potential 3rd argument.
Steffen
-
- Posts: 231
- Joined: 01 Oct 2012 13:32
- Location: Ireland
- Contact:
Re: Some undocumented things with turned off command extensions
Hi Again!
I noticed the GOTO glitch when playing around with the code developed in the Foolproof Counting of Arguments topic. I’ve boiled it down to this:
The first ECHO statement is skipped, but change the second label name and both ECHO statements will be executed!
Btw, I had to revise this post with simpler code… twice! I now realise this phenomenon has nothing to do with disabled extensions.
- SB
I noticed the GOTO glitch when playing around with the code developed in the Foolproof Counting of Arguments topic. I’ve boiled it down to this:
Code: Select all
@echo off & setlocal enableextensions disabledelayedexpansion
(
goto skip
:skip
echo(first label
)
:skip
echo(second label
endlocal & goto :eof
The first ECHO statement is skipped, but change the second label name and both ECHO statements will be executed!
Btw, I had to revise this post with simpler code… twice! I now realise this phenomenon has nothing to do with disabled extensions.
- SB
Last edited by Sponge Belly on 14 Feb 2017 12:58, edited 1 time in total.
Re: Some undocumented things with turned off command extensions
What do you mean, by saying the above?Sponge Belly wrote:The ampersand (&) can’t be used as command separator when extensions are disabled.
The following should work as always: "&", "&&", "|", "||".
The command line interpreter must read the complete "for"-loop before it is able to execute it.
Because of that the filepointer is in the line after the ")", and the next ":skip" label is the second in the batch.
If you change the second label, then the cli will find the only ":skip"-label in this batch, because it is not in the same line as the ")" line.
penpen
-
- Posts: 231
- Joined: 01 Oct 2012 13:32
- Location: Ireland
- Contact:
Re: Some undocumented things with turned off command extensions
Hi Penpen,
Thanks for explaining GOTO’s mysterious behaviour. And you don’t need the body of a FOR loop or an IF block. An unconditional parenthesized block will do. See my previous post for a simplified code example.
And you’re right about the ampersand as command separator. I don’t know what I was thinking. I've removed the erroneous postscript from my previous post.
Finally, GOTO :EOF will work with extensions disabled, but :EOF must be in capitals.
- SB
Thanks for explaining GOTO’s mysterious behaviour. And you don’t need the body of a FOR loop or an IF block. An unconditional parenthesized block will do. See my previous post for a simplified code example.
And you’re right about the ampersand as command separator. I don’t know what I was thinking. I've removed the erroneous postscript from my previous post.
Finally, GOTO :EOF will work with extensions disabled, but :EOF must be in capitals.
- SB
Re: Some undocumented things with turned off command extensions
I cannot get GOTO :EOF (nor GOTO:EOF, with or without space, in all-caps) to function with DisableExtensions unless an :EOF (or :eof) label is present.Sponge Belly wrote: ↑14 Feb 2017 13:11GOTO :EOF will work with extensions disabled, but :EOF must be in capitals.
I tested:
- on both Windows 2000 [5.00.2195] and Windows 10 [10.0.19042.1052]
- using a Command Prompt started with CMD /E:OFF and/or with SETLOCAL DISABLEEXTENSIONS in the batch files
- using .BAT and .CMD extensions
With no :EOF label present, lower case GOTO:eof fails fatally:
Code: Select all
>type EOFlower.bat
@IF ~0==%~0 ECHO/Extensions: Disabled
GOTO:eof
ECHO/Failed: GOTO:eof
>EOFlower.bat
Extensions: Disabled
>GOTO:eof
The system cannot find the batch label specified - eof
Code: Select all
>type EOFupper.bat
@IF ~0==%~0 ECHO/Extensions: Disabled
GOTO:EOF
ECHO/Failed: GOTO:EOF
>EOFupper.bat
Extensions: Disabled
>GOTO:EOF
The system cannot find the batch label specified - EOF
Code: Select all
>type EOFin.bat
@IF ~0==%~0 ECHO/Extensions: Disabled
GOTO:EOF
ECHO/Failed: GOTO:EOF
:eof
>EOFin.bat
Extensions: Disabled
>GOTO:EOF
Re: Some undocumented things with turned off command extensions
Hi CJM,
I'm not sure what Sponge Belly said with, if he said anything about adding a label or not
It's the expected behavior. With Disabled Extensions there is no implicit :EOF label anymore.
I'm not sure what Sponge Belly said with, if he said anything about adding a label or not
jebSponge Belly wrote: ↑14 Feb 2017 13:11Finally, GOTO :EOF will work with extensions disabled, but :EOF must be in capitals.