gac() {
git add .
git commit -m "$1"
}
这个函数在我的 bash 配置文件中,当我尝试获取文件时它会引发错误。
$ source ~/.bashrc
bash: /home/sahandz/.bashrc: line 176: syntax error near unexpected token `('
bash: /home/sahandz/.bashrc: line 176: `gac() {'
我不知道为什么。我有另一个函数,看起来像这样并且不会引发任何错误:
abcToTestDir() {
folderName=${1%_*}
testFolderPath="$testfilespath$folderName"
abcFilePath="$abcpath$folderName/$1"
testFilePath="$testFolderPath/$1"
mkdir -p $testFolderPath
cp $abcFilePath $testFilePath
}
我的函数定义有什么问题?
最佳答案
如果 gac
已经是一个别名,就会发生这种情况。例如在我的机器上:
$ type ls
ls is aliased to `ls --color=auto'
$ ls(){ true; }
bash: syntax error near unexpected token `('
关于bash - 在 bash 配置文件中定义函数时出现意外标记 `(' 附近的语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56408356/