bash脚本无法在其他计算机上运行

时间:2018-11-02 21:31:29

标签: bash macos

我在一台计算机上编写了一些脚本,但是粘贴到另一台计算机上的完全相同的内容无法编译。为什么不呢?

脚本为:

alias push=gitPush

gitPush() {
    branch_name=$(git branch | grep '*' | sed 's/* //')
    NUM=$(echo $branch_name | grep -o '\([0-9]\+\)')

    # push to branch
    read -p 'Do you have any files to add? ' yn

    case $yn in
       [Yy]* ) echo 'Adding...'; git add .;git commit -a -m 'ITEM-'$NUM':';git commit --amend;...;;
       * ) echo 'Acceptable input: y/n/q';;
    esac
}

case的第一行,我遇到语法错误。但是这个确切的脚本只能在一台计算机上工作。

编辑:

这是另一个失败的脚本。

cleanBranches() {
   echo 'Cleaning branches...'
   # the line below fails with:
   # syntax error near unexpected token `'refs/heads/develop''
   IGNORE_BRANCHES=('refs/heads/develop' 'refs/heads/master')
}

0 个答案:

没有答案