我正在尝试在新的bash
会话中执行一组命令:
exec bash <<- EOF
ln -snf $JDK_REPO'/jdk'$1 $CURRENT;
JAVA_HOME=$(readlink -f $CURRENT);
echo $JAVA_HOME;
export PATH= $JAVA_HOME/bin:$PATH;
exec usejdk
EOF
我收到错误:
warning: here-document at line 46 delimited by end-of-file (wanted `EOF')
我尝试用whatswrongwithmyscript调试它,我得到:
Use <<- instead of << if you want to indent the end token.
是否有建议在新 bash
实例中执行一组命令?
答案 0 :(得分:2)
cmd="
ln -snf $JDK_REPO'/jdk'$1 $CURRENT;
JAVA_HOME=$(readlink -f $CURRENT);
echo $JAVA_HOME;
export PATH= $JAVA_HOME/bin:$PATH;
exec usejdk"
bash <<< "$cmd"
bash <<< "$cmd"
相当于echo "$cmd" | bash
或bash -c "$cmd"