Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: default values
- X-seq: zsh-users 21420
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: default values
- Date: Wed, 30 Mar 2016 11:52:11 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=EOtQRIXvn7VCJtPX/ZWMvSnhsZI73Wt2q5nXa4vA3/w=; b=PxdgnYDmSBd7BoDYPF83C30p3XjRlC1Bh8OJ/RrW1/C9TbOkSN/Q6XH3UskvcoLn08 9NhM6AuAih9ez2+b7W9MZ77DKk4LeQLwSposA99rQNn08hOIWwhRMOxqKt1R0AC1cEai 5gIDD+ohOzP2sfE7bU050gdvdHz11I+ZOzVxxwibqOmMVv1waY2uBhQAb99OCQnnQbxw R8oYjUek8/+vdlxLqje8S+E5rqyModUSYu0kCaswHuXIWgTIIXnXo2llyevCXYHFof8J oVMiXecBrK4OaGkjl+4JG7gd6HPgD83fYUPLIUqAmuSgSO+E8jkGDYliPTRo2TDyq74l gAXw==
- In-reply-to: <87twjnn8bn.fsf@debian.uxu>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <87twjnn8bn.fsf@debian.uxu>
On Mar 30, 8:12pm, Emanuel Berg wrote:
}
} Is there a C-like "... ? ... : ... ;" syntax or
} otherwise standard or conventional way to assign
} default values to sometimes-not-submitted parameters?
In math context you can actually use ternary syntax:
$(( x ? y : z ))
But I think you're actually looking for this:
${NAME-WORD}
${NAME:-WORD}
If NAME is set, or in the second form is non-null, then substitute
its value; otherwise substitute WORD. In the second form NAME may
be omitted, in which case WORD is always substituted.
So e.g.
local num_files=${1:-10}
local where=${2:-./}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author