【发布时间】:2014-07-08 15:32:33
【问题描述】:
我正在浏览其他人编写的 shell 脚本。我可以在脚本开始时看到以下几行。我知道它必须与路径和所有东西有关。但是任何人都可以解释它是如何工作的吗?
#!/bin/ksh
scripttorun=${0}
scriptname=${0##/*/}
scriptname=$(basename $0)
scriptpath=${0%%/$scriptname}
if [ $scriptpath != $0 ];then
cd $scriptpath
fi
【问题讨论】: