Dummy command in windows cmd

前端 未结 4 1466
粉色の甜心
粉色の甜心 2021-01-17 10:49

In linux we have a makefile:

$(foreach A,a b,echo $(A) &&) true

It works and echos

a
b

Now we wan

相关标签:
4条回答
  • 2021-01-17 11:09

    The rem command does nothing.

    0 讨论(0)
  • 2021-01-17 11:17

    There is no single answer as to which dummy command is shortest, because there are several different purposes (contexts) for the dummy command that may lead to different choices. Listing from best to worst.

    @ excels in length and in doing nothing. It works well at the end of the command line.

    rem is great, and in command.com times it used to be a command, so it worked even with input/output redirection. Today (in cmd.exe) it starts a comment, so it is only usable at the end of a command line; any redirection would end up commented out, too.

    echo. works even with input/output redirection. That dot does not get printed, echo state is not altered. If used on the beginning of a command batch, you might need to spell it @echo. if you do not want the dummy command itself to be echoed to the standard output; but that's not special to the echo command.

    cd. is the counterpart of true in Linux. Frame challenging the OP, it actually does something specific: it sets ERRORLEVEL to 0. It works with redirection.

    call is the counterpart of false in Linux. The command thinks it deserves to be told what to call, but if you didn't mention any, it lets you go without any error message, but setting ERRORLEVEL to a positive value. It works with redirection.

    (This summary draws on three existing answers, plus this answer to another question on another site. Attempting an old fashioned canonical answer.)

    0 讨论(0)
  • 2021-01-17 11:25

    Old thread, new answer.

    I have been using cd. when I want to do nothing in windows (and I often do) since "change directory to itself" has no side effects at all as far as I can see.

    0 讨论(0)
  • 2021-01-17 11:36

    The call command without any argument does nothing and has no collateral effect as rem has.

    Example:

    echo Wait for it...
    call
    echo Nothing happened!
    
    0 讨论(0)
提交回复
热议问题