Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
2 Stylistic and grammar edits
source | link

How can I write a function in zshzsh that invokes an existing command with the same name as the function itself? For example, I've tried this to illustrate my question:

function ls 
{
    ls -l $1 $2 $3
}

But I see this whenWhen I execute it with ls * I get the following:

ls:1: maximum nested function level reached

I assume this is because the function is being called recursively. How I can avoid thisthat?

(this This is a crude example, and in this case an alias would do the job, but I have a more complex example where an alias isn't suitable and so I would need to write a function).

How can I write a function in zsh that invokes an existing command with the same name as the function itself? For example, I've tried this to illustrate my question:

function ls 
{
    ls -l $1 $2 $3
}

But I see this when I execute it with ls *:

ls:1: maximum nested function level reached

I assume this is because the function is being called recursively. How I can avoid this?

(this is a crude example, and in this case an alias would do the job, but I have a more complex example where an alias isn't suitable and so I need to write a function).

How can I write a function in zsh that invokes an existing command with the same name as the function itself? For example, I've tried this to illustrate my question:

function ls 
{
    ls -l $1 $2 $3
}

When I execute it with ls * I get the following:

ls:1: maximum nested function level reached

I assume this is because the function is being called recursively. How I can avoid that?

This is a crude example, and in this case an alias would do the job, but I have a more complex example where an alias isn't suitable and so I would need to write a function.

    Tweeted twitter.com/#!/StackUnix/status/305443167346507776
1
source | link

How can I create a function in zsh that calls an existing command with the same name?

How can I write a function in zsh that invokes an existing command with the same name as the function itself? For example, I've tried this to illustrate my question:

function ls 
{
    ls -l $1 $2 $3
}

But I see this when I execute it with ls *:

ls:1: maximum nested function level reached

I assume this is because the function is being called recursively. How I can avoid this?

(this is a crude example, and in this case an alias would do the job, but I have a more complex example where an alias isn't suitable and so I need to write a function).