【发布时间】:2017-09-30 02:43:15
【问题描述】:
我正在尝试整合我的点文件,因此我只有一套用于本地 OSX 机器和 Linux 服务器。我有这个条件语句,但 $(brew --prefix) 正在 Linux 机器上运行,即使该块不应该运行......
SYSTEM=`uname -a | cut -d" " -f1`
# These things are system specific
if [ $SYSTEM=="Darwin" ]; then
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
for file in ~/.completion/* ; do
if [ -f "$file" ] ; then
. "$file"
fi
done
elif [ $SYSTEM=="Linux" ]; then
alias upgrade='sudo apt-get update && sudo apt-get upgrade'
# save the IP address in case I need it later
export IP_ADDRESS=`ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
fi
如果我在 linux 机器上回显 $SYSTEM 变量,它说它是 Linux,但在 brew --prefix 命令上获取 bashrc 失败。
无论如何它都会评估该变量吗?有什么办法可以让它工作吗?
【问题讨论】:
-
尝试
==周围的空格。另请注意stackoverflow.com/questions/2237080/… -
提示:ShellCheck会自动识别this issue等常见问题。
标签: bash