How to use newline character in text in cmd batch?

后端 未结 12 1844
忘掉有多难
忘掉有多难 2020-12-31 07:08

I would like to do

svn commit -m \"\"

But message should have two lines:

Commit by: firstuser
Bug track: 92         


        
相关标签:
12条回答
  • 2020-12-31 07:16

    How about using the -F parameter to get the log message from a file?

    Then, you could do this (untested):

    ECHO Commit by: firstuser>SvnLog.txt
    ECHO Bug track: 9283>>SvnLog.txt
    
    SVN COMMIT -F SvnLog.txt
    
    0 讨论(0)
  • 2020-12-31 07:18

    You can define the newline as follows:

    set newline=^& echo.
    

    Then, you can use the newline in other statements, like this: (no quotes)

    echo This is the first line%newline%This is the second line
    echo "This is the first line"%newline%"This is the second line"
    

    or with an extra caret, like this:

    set text=This is the first line^%newline%This is the second line
    

    Perhaps you can play with that, but mind the combination with quotes!

    0 讨论(0)
  • 2020-12-31 07:23

    Additional example to @jeb's answer

    answer:

    set br= ^
    <</br (newline)>>
    <</br>>
    

    example:

    @echo off
    setlocal enableExtensions enableDelayedExpansion
    rem cd /D "%~dp0"
    set br= ^
    
    
    rem br, can't be saved to a var. by using %..%;
    
    
    set "t=t1!br!t2!br!t3"
    
    for /f "usebackq tokens=* delims=" %%q in ('!t!') do (
        echo %%q
    )
    
    
    :scIn
    rem endlocal
    pause
    rem exit /b
    

    ; output:

    t1
    t2
    t3
    Press any key to continue . . .
    
    0 讨论(0)
  • 2020-12-31 07:25

    Write the message in text editor and just copy and paste it to terminal(command editor).

    1. Just type message in a text editor in multiple lines.

      -m "Message line

      Message line 2

      Message line 3"

    2. Type the required command in command editor.

      svn command

    3. Copy and paste the message content from text editor to command editor.

      svn command -m "Message line 1.

      Message line 2

      Message line 3"

    4.Execute Enter .

    5.It works :)

    0 讨论(0)
  • 2020-12-31 07:31

    Just write svn ci -m "old line press Enter then type in next line new line"

    Example

    This is much easier than using file.

    0 讨论(0)
  • 2020-12-31 07:32

    To create a newline in a svn message the best way is the one of aphoria with an extra message-file.

    But it can be done also with the -m

    Sample with a batch file

    @echo off
    SETLOCAL ENABLEDELAYEDEXPANSION
    set lf=^
    
    
    rem ** Two empty lines are neccessary for creating the Linefeed
    svn commit -m "A!lf!Message!lf!with!LF!newline"
    

    You could also use it on the command line

    svn commit -m ^"This is a^
    MORE?
    MORE?my newline"
    
    0 讨论(0)
提交回复
热议问题