
Reply is below quoted content. On Monday, March 17, 2025 11:09:43 a.m. Eastern Daylight Saving Time Giles Orr via talk wrote:
On Mon, 17 Mar 2025 at 10:16, D. Hugh Redelmeier via talk
<talk@gtalug.org> wrote:
From: Giles Orr via talk <talk@gtalug.org>
$ gr() { grep --color=auto "$@" ; } bash: syntax error near unexpected token `('
Does this tell you anything interesting?
$ type 'gr' $ type gr
Does it ever. On all the other machines:
gr is a function gr () { grep --color=auto "$@" }
But on the machine in question:
$ type gr gr is aliased to `grep --color=auto '
(Same answer whether I ask `type 'gr'` or `type gr`.)
I was initially unable to determine where that alias was being set, but when I did `unalias gr` I could then set the "gr" function without Bash complaining, so that's clearly the problem! (The alias was being set by a very old file in /etc/ ...) Thank you so much.
I think it is because bash will expand an alias if and only if it is at the beginning of a statement. If you define the function as `function gr () { ... } `, it should not experience the same problem. Best regards, tusooa