为什么回声通过管道传输到 p4 作业 -i 添加 space 和换行符
Why does an echo piped to p4 job -i add a space and newline
我在更新 perforce 作业时使用管道和使用文件输入时遇到以下差异:
进行更新时(在 windows cmd shell 中)如下:
(echo job: job00101&echo.status: open&echo.description: One line only)|p4.exe -p myServer:1234 -u myUser job -f -i
职位描述末尾多了一个空白,多了一个空行。 (可见,用P4V编辑作业时)
当我尝试使用两个命令和一个中间文件进行相同操作时
(echo job: job00101&echo.status: open&echo.description: One line only) >test.txt
p4.exe -p myServer:1234 -u myUser job -f -i <test.txt
描述只有一行,没有尾随空白。这也是我在使用管道时所期望的。
我需要的是不需要中间文件的单行命令。而且我不明白为什么管道的工作方式与文件输出和输入不同。
我认为 cmdline 重定向在 DOS 批处理中被严重破坏。 Powershell 是一个选项吗?
"job: job00101`nstatus: open`ndescription: One line only" | p4.exe -p myServer:1234 -u myUser job -f -i
作为替代方案,如果您必须是来自 DOS 批处理的 运行,您可以使用这个:
powershell -Command "\"job: job00101`nstatus: open`ndescription: One line only\" | p4.exe -p myServer:1234 -u myUser job -f -i"
我在更新 perforce 作业时使用管道和使用文件输入时遇到以下差异: 进行更新时(在 windows cmd shell 中)如下:
(echo job: job00101&echo.status: open&echo.description: One line only)|p4.exe -p myServer:1234 -u myUser job -f -i
职位描述末尾多了一个空白,多了一个空行。 (可见,用P4V编辑作业时)
当我尝试使用两个命令和一个中间文件进行相同操作时
(echo job: job00101&echo.status: open&echo.description: One line only) >test.txt
p4.exe -p myServer:1234 -u myUser job -f -i <test.txt
描述只有一行,没有尾随空白。这也是我在使用管道时所期望的。
我需要的是不需要中间文件的单行命令。而且我不明白为什么管道的工作方式与文件输出和输入不同。
我认为 cmdline 重定向在 DOS 批处理中被严重破坏。 Powershell 是一个选项吗?
"job: job00101`nstatus: open`ndescription: One line only" | p4.exe -p myServer:1234 -u myUser job -f -i
作为替代方案,如果您必须是来自 DOS 批处理的 运行,您可以使用这个:
powershell -Command "\"job: job00101`nstatus: open`ndescription: One line only\" | p4.exe -p myServer:1234 -u myUser job -f -i"