Why this code says echo is off?

前端 未结 5 1845
灰色年华
灰色年华 2021-02-05 01:46

What is wrong with this code? It says ECHO is off.

@ECHO off
set /p pattern=Enter id:
findstr %pattern% .\\a.txt > result
if %errorlevel%==0 (
se         


        
5条回答
  •  不知归路
    2021-02-05 02:17

    If your variable is empty somewhere, it will be the same as having the command "echo" on its own, which will just print the status of echo.

    To avoid this, you should replace all your echo commands with something like this:

    echo var2: %var2%
    

    That way, if %var2% is empty it will just print "echo var2:" instead of "echo off".

提交回复
热议问题