windows - CMD skips a line in batch file for no apparent reason, so what's the reason? -


simply script, simple question:

set /p customsettings="some input prompt: " if /i %customsettings:~0,1% equ y echo output 

   ^-this works fine...

set custom=1 if %custom% equ 1 (     set /p customsettings="some input prompt: "     echo output ) 

   ^-...and works fine.
why doesn't work fine?:

set custom=1 if %custom% equ 1 (     set /p customsettings="some input prompt: "     if /i %customsettings:~0,1% equ y echo output ) 

the set /p customsettings line skipped when pinched between 2 if-statements.

i'm curious why happens, , how fix it.

note: problem still persists regardless of enabledelayedexpansion's setting.

you can read lot delayed expansion on site. entire if/for construct (or multiple lines within parens) loaded , expanded 1 line. have consider load-time behavior , run-time behavior. try this:

@echo off setlocal enabledelayedexpansion set custom=1 if %custom% equ 1 (     set /p customsettings="some input prompt: "     if /i "!customsettings:~0,1!"=="y" echo output ) 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -