zsh-users
 help / color / mirror / code / Atom feed
* default values
@ 2016-03-30 18:12 Emanuel Berg
  2016-03-30 18:52 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Emanuel Berg @ 2016-03-30 18:12 UTC (permalink / raw)
  To: zsh-users

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 -                   


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-03-30 19:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-30 18:12 default values Emanuel Berg
2016-03-30 18:52 ` Bart Schaefer
2016-03-30 19:35   ` Emanuel Berg

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).