Re: Can a Bash function be named "w3m" ?
Roger Price <debian@rogerprice.org> writes:
> On a Debian 12 machine with bash 5.2.15-2+b7, I had this alias in my .bashrc
>
> alias w3m='/usr/bin/w3m -no-cookie -o auto-image=TRUE '
>
> I understand that aliases are frowned on and should be written as functions, so
> I wrote
>
> [[ $(type -t w3m) == "w3m" ]] && unalias w3m
Shouldn't that be
[[ $(type -t w3m) == "alias" ]] && unalias w3m
?
> w3m() { /usr/bin/w3m -no-cookie -o auto-image=TRUE $@ ; }
>
> and received the error message
>
> bash: .bashrc: line 86: syntax error near unexpected token `('
> bash: .bashrc: line 86: `w3m() { /usr/bin/w3m -no-cookie -o auto-image=TRUE $@ ; }'
>
> To fix this, I remove the numeral 3 from w3m, write wm() ... and then the error
> disappears. But the bash man page says that numerals are allowed in names
> although it doesn´t say if a name can be a function name:
>
> name A word consisting only of alphanumeric characters and underscores, and
> beginning with an alphabetic character or an under‐score.
>
> The man page also says that a function name is an fname (not a name), and says
> "a function name can be any unquoted shell word that does not contain $".
>
> Nothing in the man page appears to reject w3m so I do not understand why my
> function name w3m is refused.
>
> Roger
>
--
This signature is currently under constuction.
Reply to: