zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zzapper <zsh@rayninfo.co.uk>
Cc: Zsh-Users List <zsh-users@zsh.org>
Subject: Re: Can I test if a parameter expansion has worked
Date: Wed, 14 Sep 2022 11:36:38 -0700	[thread overview]
Message-ID: <CAH+w=7aLhYhSNFKU1Z=ZM4fGSQ2dLUSr+akwtN2Ec_vNyqeHrg@mail.gmail.com> (raw)
In-Reply-To: <5dc8b935-f234-ca54-0ceb-50cb1da9bc29@rayninfo.co.uk>

On Wed, Sep 14, 2022 at 9:52 AM zzapper <zsh@rayninfo.co.uk> wrote:
>
> Q1) Can I test if a parameter expansion has 'fired'?

I'm not sure what that means.  Does 'fired' mean expanded to a
non-empty string, as in, the parameter has a value?  And, test when,
relative to the placement of the parameter reference?  And, what do
you want to do based on the result of the test?

The most obvious answer would be that ${param:?} will cause a fatal
error if the parameter is either unset or empty, but that doesn't
provide any avenue for recovery unless you use an "always" block
around it.


  reply	other threads:[~2022-09-14 18:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-14 10:03 zzapper
2022-09-14 18:36 ` Bart Schaefer [this message]
2022-09-15  0:08 ` Alex Satrapa
2022-09-15  7:34 ` zzapper
2022-09-15  8:24   ` Peter Stephenson
2022-09-15  8:38     ` zzapper
2022-09-15 16:48   ` Bart Schaefer
2022-09-20  7:14     ` david rayner
2022-09-16  0:41   ` Alex Satrapa
2022-09-20 12:49   ` Stephane Chazelas
2022-09-20 13:25   ` Stephane Chazelas
2022-09-20 13:31     ` Stephane Chazelas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7aLhYhSNFKU1Z=ZM4fGSQ2dLUSr+akwtN2Ec_vNyqeHrg@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@zsh.org \
    --cc=zsh@rayninfo.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).