zsh-users
 help / color / mirror / code / Atom feed
From: Eric Nielsen <ericbn@hey.com>
To: "zsh-users@zsh.org" <zsh-users@zsh.org>,  sergio <sergio@outerface.net>
Subject: Re: join a string with a parameter value if it's not empy
Date: Fri, 03 Feb 2023 19:20:12 -0500	[thread overview]
Message-ID: <6e1b26963200efd1c6e7ed9a0dd976ded1ab72c9@hey.com> (raw)
In-Reply-To: <81c93630-34fd-7e2d-39bb-e5f8cc5b344e@outerface.net>

[-- Attachment #1: Type: text/plain, Size: 169 bytes --]

> p='value' -> result: 'value_string'
> p='' -> result: 'string'

A simpler variation of your first solution:

$p${p:+_}string


--
Sent with HEY <https://hey.com/sent>

[-- Attachment #2: Type: text/html, Size: 2742 bytes --]

  reply	other threads:[~2023-02-04  0:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-03 23:43 sergio
2023-02-04  0:20 ` Eric Nielsen [this message]
2023-02-04  2:01   ` sergio
2023-02-04  3:30     ` Eric Nielsen
2023-02-04  4:03     ` Bart Schaefer
2023-02-04  8:39       ` Stephane Chazelas
2023-02-04  0:23 ` Eric Nielsen

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=6e1b26963200efd1c6e7ed9a0dd976ded1ab72c9@hey.com \
    --to=ericbn@hey.com \
    --cc=sergio@outerface.net \
    --cc=zsh-users@zsh.org \
    /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).