【发布时间】:2020-10-20 19:47:58
【问题描述】:
我对 linux 中的 shell 脚本或命令几乎一无所知
我有一个名为projectx的项目
projectX恰好在users/hardik/desktop/projectx中
我创建了一个 shell 脚本start.sh。这是shell脚本的内容
echo "Starting typescript build in new terminal.."
osascript -e 'tell application "Terminal" to do script "npm run build"'
sleep 3
echo "Starting firebase functions...."
osascript -e 'tell application "Terminal" to do script "firebase emulators:start --only functions"'
echo "Process compelete.. Check if there were two terminals window open"
现在可以了,但在这里说
osascript -e 'tell application "Terminal" to do script "npm run build"'
它在根目录中运行,因此出现以下错误
ENOENT:没有这样的文件或目录,打开/Users/hardik/package.json
如何让它在相对于start.sh的路径中执行
更新:我试过了
echo "Starting typescript build in new terminal.."
path=`pwd`
osascript -e 'tell application "Terminal" to do script "cd ${path} npm run watch:scss"'
osascript -e 'tell application "Terminal" to do script "npm run watch"'
echo "Process compelete.. Check if there were two terminals window open"
但这不适用于错误cd: too many arguments
【问题讨论】:
标签: macos unix command-line command-line-interface