On Thu, Jan 30, 2025 at 01:59:37PM +0100, Roger Price wrote:
> 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

Wait a minute...

>  [[ $(type -t w3m) == "w3m" ]] && unalias w3m
>  w3m() { /usr/bin/w3m -no-cookie -o auto-image=TRUE $@ ; }

...the problem is that the command w3m exists: the shell
expands that thing and tries to run it -- the parentheses
then are a syntax error.

Thing is, the line as you wrote it is ambiguous whenever the shell
knows how to "run" w3m: shall it run it, or are you trying to define
a function?

The shell decides for the first.

Try prefixing the thing with the builtin `function':

  function w3m() ...

Cheers
-- 
t

Attachment: signature.asc
Description: PGP signature

Reply via email to