[英]syntax error near unexpected token `(' when defining function in bash profile
gac() {
git add .
git commit -m "$1"
}
This function is in my bash profile, and it raises an error when I try to source the file. 此函数在我的bash配置文件中,当我尝试获取该文件时会引发错误。
$ source ~/.bashrc
bash: /home/sahandz/.bashrc: line 176: syntax error near unexpected token `('
bash: /home/sahandz/.bashrc: line 176: `gac() {'
I can't figure out why. 我不知道为什么。 I have another function that looks like this and doesn't raise any error:
我有另一个函数,看起来像这样,不会引发任何错误:
abcToTestDir() {
folderName=${1%_*}
testFolderPath="$testfilespath$folderName"
abcFilePath="$abcpath$folderName/$1"
testFilePath="$testFolderPath/$1"
mkdir -p $testFolderPath
cp $abcFilePath $testFilePath
}
What is wrong with my function definition? 我的函数定义有什么问题?
This can happen if gac
is already an alias. 如果
gac
已经是别名,则可能发生这种情况。 For example on my machine: 例如在我的机器上:
$ type ls
ls is aliased to `ls --color=auto'
$ ls(){ true; }
bash: syntax error near unexpected token `('
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.