this question seems frequently asked but still there is no satisfying answer regarding my issue. Hence, I was hoping you could help me out.
The following error occurs opening a terminal under Ubuntu LTE 13.04:
syntax error near unexpected token
done' bash: /usr/share/bash-completion/bash_completion: line 225:
done'
I checked the specific 'bash_completion' - seems fine. Furthermore, I narrowed it down to the following command in my .bashrc file.
alias do='rsync -r -e ssh --exclude='file.py' [email protected]:/path/to/folder /do/here'
Though the following works just perfectly without raising any exceptions:
alias up='rsync -r -e ssh --exclude='file.py' /path/to/folder [email protected]:/do/here'
I checked if it does occur because of the --exclude
flag, but it doesn't. Seems like something is wrong with the command. Though both commands just perfectly do their job. Only the first raises the error.
Any ideas ?
In bash, do
is a reserved word. It's looking for a do ... done
block. Just name your alias something else.
do
is a shell keyword. You can't use it as an alias name without causing bugs.
Beyond that -- consider using functions rather than aliases; they provide substantially more control. This alias might be rewritten as so:
do_sync() {
rsync -r -e ssh --exclude='file.py' \
[email protected]:/path/to/folder \
/do/here \
"$@"
}
Using functions instead of aliases lets you do conditional logic, insert arguments in a position other than the tail, and significantly simplifies quoting (which, for your alias here, almost certainly wasn't doing what you wanted it to, since you were using the same quote type both around the alias text and within the alias text with no escaping).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With