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

default values



Is there a C-like "... ? ... : ... ;" syntax or
otherwise standard or conventional way to assign
default values to sometimes-not-submitted parameters?

I have found many ways to do it and I can't tell if
one is better than the other.

For example, like this:

    biggest-files () {
        local num_files=10
        local where=./

        if [ $1 ]; then num_files=$1; fi
        if [ $2 ]; then     where=$2; fi

        du -ahS $where | sort -hr | head -n $num_files
    }

How is this supposed to look?

-- 
underground experts united .... http://user.it.uu.se/~embe8573
Emacs Gnus Blogomatic ......... http://user.it.uu.se/~embe8573/blogomatic
                   - so far: 20 Blogomatic articles -                   



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