Search code examples
functionfindargumentszsh

Passing all arguments in zsh function


I am trying to write a simple function in my .zshrc that hides all the errors (mostly "Permission denied") for find.

Now, how can I pass all the arguments given by calling the function to find?

function superfind() {
    echo "Errors are suppressed!"
    find $(some magic here) 2>/dev/null
}

I could do $1 $2 $3 $4 ... but this is stupid! I am sure there is a really simple way.


Solution

  • Use $@, it expands to all the positional arguments, e.g.:

    superfind () {
        echo "Errors are suppressed!"
        find "$@" 2> /dev/null
    }