[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: function def crash
From: |
Phi Debian |
Subject: |
Re: function def crash |
Date: |
Thu, 24 Jun 2021 16:07:29 +0200 |
Yes figured the hard way :)
Thanx
On Thu, Jun 24, 2021 at 1:51 PM Greg Wooledge <greg@wooledge.org> wrote:
> On Thu, Jun 24, 2021 at 09:48:59AM +0200, Phi Debian wrote:
> > $ function echo { \echo the function version; \echo "$@"; }
>
> For the record, this isn't how you write a function that wraps a builtin.
> Use the "builtin" command instead.
>
> echo() {
> printf 'echo() wrapper invoked.\n'
> builtin echo "$@"
> }
>
> Or, if you aren't sure whether the command you're wrapping is a builtin
> or a program, use "command":
>
> echo() {
> printf 'echo() wrapper invoked.\n'
> command echo "$@"
> }
>
> The backslash hack only stops aliases from being used. It doesn't stop
> your function from calling itself recursively.
>
>