Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Alias call in function fails...



On 6/22/20, Frank Gallacher <franxg@xxxxxxxxx> wrote:
> Greetings,
>
> I have a function:
>
[...]
>
> Which calls an alias:
>
> alias dumpit='hexdump -C -n 128'
>
> It works fine in bash, but with zsh now I get:
>
> :::::::: test.txt ::::::::
> dumpall:11: command not found: dumpit
>
> Am I doing something wrong???

Yes, don't use aliases for anything but interactive usage. Eg if you
want to use dumpit in a script, make it be a function:
dumpit() { hexdump -C -n 128 }

Aliases are expanded on parse time, which means aliases defined in a
file won't be usable in that same file. (Because it is parsed in its
entirety before any of the code is actually run).

-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author