bash 为什么我收到“svn: command not found”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33336496/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why am I getting "svn: command not found"
提问by user3277807
I'm wondering if anyone can help with figure out why my simple bash script is not working, I keep getting:
我想知道是否有人可以帮助弄清楚为什么我的简单 bash 脚本不起作用,我不断收到:
svn:command not found
svn:找不到命令
even though I have svn installed and it works perfectly outside of my script.
即使我已经安装了 svn 并且它在我的脚本之外也能完美运行。
#!/bin/bash
## Get Directory Path From User
printf "\n";
printf "Uses of ~/ or . To Designate Directory Structure Will Not Work!\n"
printf "\n";
printf "Please Enter The FULL Path To The Directory\n"
printf "Where We Shall Create Copy of Slides\n"
read PATH
## If Path Is Valid
if [ -d "$PATH" ]; then
printf "Valid Path To Directory Entered\n"
## Attempt To Copy Files From SVN On Bluenose
`svn checkout https://svn.cs.dal.ca/csci2132/all/slides/ $Path`
printf "All Slides Have Been Copied To "
printf $PATH + "\n"
printf "\n"
## Invalid Path Entered Tell User And Exit
else
printf "Invalid Path Entered\n";
printf "Please Try Again\n";
exit 0;
fi
printf "Task Complete\n"
回答by William Pursell
The shell looks through the colon separated list of directories in PATH to find executables. Since you have used the name PATH to be the target destination, that is where it is looking for svn. Just choose a different name for the variable. That is, do not overwrite PATH.
shell 在 PATH 中查找以冒号分隔的目录列表以查找可执行文件。由于您使用名称 PATH 作为目标目的地,这就是它寻找 svn 的地方。只需为变量选择一个不同的名称。也就是说,不要覆盖 PATH。