Escaping a batch file echo that starts with a forward slash and question mark

前端 未结 2 1935
忘掉有多难
忘掉有多难 2020-12-10 06:49

Bit of a tricky one. How can I correctly escape the following in a batch file?

echo    /?   display this help text

This particular combina

相关标签:
2条回答
  • 2020-12-10 07:22

    For escaping echo arguments exists many variants, like echo., echo:, echo=
    But only echo( seems to be secure against any appended text.

    These one fails, if files exists like echo, echo[, echo] or echo+

    echo.
    echo[
    echo]
    echo+

    These one fails, if a file in the current directory exists named my.bat

    echo\..\my.bat
    echo:\..\my.bat
    echo.\..\my.bat

    These one fails independet of a file

    echo/?
    echo,/?
    echo;/?

    Only the echo( seems to be always safe against any content

    0 讨论(0)
  • 2020-12-10 07:44

    For escaping echo arguments, you can use the alternative syntax echo.:

    echo./?
    
    0 讨论(0)
提交回复
热议问题