Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
default values
- X-seq: zsh-users 21419
- From: Emanuel Berg <embe8573@xxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: default values
- Date: Wed, 30 Mar 2016 20:12:44 +0200
- Cancel-lock: sha1:s5UCF+FX/b9zw8RvUoizv/CEgeA=
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mail-copies-to: never
- Mail-followup-to: zsh-users@xxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
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