阻止gitbash自动更改路径



当我在gitbash中运行一些代码时,我发现路径被自动更改了。

$ python src/loon/skeleton.py  upload ~/test.R /tmp -v
[2019-11-03 10:41:07] INFO:__main__:Starting loon...
[2019-11-03 10:41:07] INFO:__main__:Upload command is detected.
=> Starting upload...
[2019-11-03 10:41:07] INFO:__main__:Running scp -pr -P 22 C:/Users/Administrator/test.R wangshx@10.15.22.110:C:/Users/ADMINI~1/AppData/Local/Temp/
scp: C:/Users/ADMINI~1/AppData/Local/Temp/: No such file or directory
[2019-11-03 10:41:08] INFO:__main__:Status code: 1
Error: an error occurred, please check the info!

这里的/tmp是远程主机上的路径。您可以看到/tmp已更改为C:/Users/ADMINI~1/AppData/Local/Temp/。我不能通过添加'"来阻止它。

$ python src/loon/skeleton.py  upload ~/test.R '/tmp' -v
[2019-11-03 10:43:17] INFO:__main__:Starting loon...
[2019-11-03 10:43:17] INFO:__main__:Upload command is detected.
=> Starting upload...
[2019-11-03 10:43:17] INFO:__main__:Running scp -pr -P 22 C:/Users/Administrator/test.R wangshx@10.15.22.110:C:/Users/ADMINI~1/AppData/Local/Temp/
scp: C:/Users/ADMINI~1/AppData/Local/Temp/: No such file or directory
[2019-11-03 10:43:19] INFO:__main__:Status code: 1
Error: an error occurred, please check the info!

这是因为Git Bash试图提供帮助,并将Linux路径转换为Windows路径。

如果将MSYS_NO_PATHCONV=1添加到命令的开头,它将告诉gitbash不要用Temp目录替换/tmp。您的命令将如下所示:

MSYS_NO_PATHCONV=1 python src/loon/skeleton.py upload ~/test.R /tmp -v

解决方案基于另一个问题。

相关内容

  • 没有找到相关文章