bash - bash 脚本在不同的计算机上不起作用
问题描述
我在一台计算机上编写了一些脚本,但粘贴到另一台计算机上的完全相同的内容无法编译。为什么不?
脚本是:
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')
}
解决方案
推荐阅读
- php - Composer 无法从供应商目录中的存储库中找到类
- c++ - 用于初始化指向实例化模板友元函数的指针的 C++ 语法
- python - 从 Pandas DataFrame 返回 NaN 值的相关矩阵
- python - 找不到满足 flask-restfull 要求的版本(来自版本:)
- git - --assume-unchanged 文件在同步时会发生什么?
- python - 遍历列表在 Python 中的行为如何?
- r - 在 R 中安装 devtools 时的依赖性问题
- spring - Spring JdbcTemplate 更新 Postgis 地理专栏
- ios - NSObject 在加载 viewDidLoad() 之前似乎没有初始化
- javascript - 使用预定义的 X 轴绘制不规则日期时间数据