[英]Change directory through bash script without messing up $PATH
Yes, I know that I can run 是的,我知道我可以跑步
. my_cd_script.sh
to change my directory directly. 直接更改我的目录。 However, once I do that, my
$PATH
is messed up. 但是,一旦这样做,我的
$PATH
就被搞砸了。 For instance, when I type ls
, the shell will return Command not found
. 例如,当我键入
ls
,shell将返回Command not found
。
Anyone encountered this? 有人遇到过这个吗?
I named a variable "path" without a second thought, although I would've expected shell to be case sensitive. 尽管我希望shell区分大小写,但我毫不犹豫地将变量命名为“ path”。 – user1836155
– user1836155
If you're running into variable names not seeming to be case-sensitive, then I suspect you're not actually using bash
. 如果您遇到的变量名似乎不区分大小写,那么我怀疑您实际上并没有使用
bash
。 Maybe csh
instead, or some other variant in the csh
family... – twalberg 也许是
csh
替代,或者csh
家族中的某些其他变体... – twalberg
I used the "#!/bin/bash" header though – user1836155 我虽然使用了“#!/ bin / bash”标题– user1836155
The header means nothing when you source a file with . myscript
使用来源文件时,标头没有任何意义
. myscript
. myscript
- it's just a comment in that case. . myscript
在这种情况下只是一个评论。 – twalberg – twalberg
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.