Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
259 views
in Technique[技术] by (71.8m points)

macos - source .zshrc command fails when adding ~/omnetpp-5.6.2/bin to PATH

adding export PATH= $PATH:~/omnetpp-5.6.2/bin to .zshrc in MacOS gives the following error :

.zshrc:export:193: not valid in this context: /usr/local/opt/gcc/bin:/usr/local/bin/python3:/usr/local/opt/gcc/bin:/usr/local/bin/python3:/Users/kaytlyn/anaconda3/bin:/Users/kaytlyn/anaconda3/condabin:/usr/local/opt/gcc/bin:/usr/local/bin/python3:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/usr/local/share/dotnet:/opt/X11/bin:~/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Wireshark.app/Contents/MacOS:/Users/kaytlyn/anaconda3/bin:/usr/local/go/bin/go:/Users/kaytlyn/anaconda3/bin:/usr/local/go/bin/go:/Users/kaytlyn/anaconda3/bin:/usr/local/go/bin/go:~/omnetpp-5.6.2/bin prompt_status:5: command not found: wc

I want to add this path so that I don't have to cd to that directory every time to run it. How do solve this problem? Thanks in advance!!

question from:https://stackoverflow.com/questions/65861819/source-zshrc-command-fails-when-adding-omnetpp-5-6-2-bin-to-path

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

~ does not get expanded to /Users/kaytlyn if you add it that way. Try this instead:

# Use the array version instead of the scalar.
# -U eliminates duplicates.
export -U PATH path+=( ~/omnetpp-5.6.2/bin )

See http://zsh.sourceforge.net/Doc/Release/Parameters.html#Parameters-Used-By-The-Shell


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...