Why filename is not getting rendered properly

前端 未结 2 1733
自闭症患者
自闭症患者 2021-01-27 15:46

I am in need to redirect output of program to a file and below is the code that I am using to create the output log file name:

set filename \"C:\\tools\\tcl\\bin         


        
2条回答
  •  感动是毒
    2021-01-27 16:30

    Tcl will do backslash substitution and these substitution will happen only with double quotes. If you need a literal backslash, you have to escape it. When enclosed with braces, these substitution will not happen.

    So, you can define your variable as

    set filename "C:\\tools\\tcl\\bin\\my.log"
    

    or

    set filename {C:\tools\tcl\bin\my.log}
    

    About the command line argument stuff, don't bother. Tcl will take care of it. It will be received as it is from your terminal.

提交回复
热议问题