From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HTML_MESSAGE,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 3312 invoked from network); 4 Feb 2023 00:26:29 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 4 Feb 2023 00:26:29 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1675470389; b=eP0ej6CnGQpsg8mMxkH9nDxDfpVbV/oKxrwMAS5yCk0Lud+pvWiLbY9OANwQ56wLdM+KWqhG1a EapKMkbkGR3wso0Q+R529wWBNcp3zL9L9LsDpBlQz/QYko44mP5kDHHIHoLnwzeP46sxDuac3J uOYzWpuidwWdCZuP5pAFB8ESa+q2zNHPxpEHvfZnyJQg/n1jGy3F0JSp563paSirV1mlRn+vvT VrYMJUd1cATxuWqqrvGqWCLunt1SzHB2e+UutqXQiSTPPy3r9sduC72uhz7QU3CuztB9QO6YPZ kflYpBsIKgPfVOMnbpjQAcTz5iHvvd47HVEBcllzz9qNHQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (02d.relay.hey.com) smtp.remote-ip=204.62.114.231; dkim=pass header.d=hey.com header.s=heymail header.a=rsa-sha256; dmarc=pass header.from=hey.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1675470389; bh=O231JAv0srCfUfju7UntDDyshl85bMjg2u0LScNKNXU=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject: In-Reply-To:Message-ID:To:From:Date:DKIM-Signature:DKIM-Signature; b=TzhHaZp4+/xRup3ZAvalYyR2OGWvEi5bZ/Oe3XK4MOo5+gArQ4IIGQvOxqkKEgpgtcbsR1kVBd BcOEnyLDptfkLc16pjr5qfp9HMrkz6rc29MDnXvDwlzWF9kHqI9cIkaXUGozDsgt83Ii9B5IjC NvTCV+NEN/Ueymrpm9gGW3usVYtDl3akSQ9hg4QPKyGIXECmqSXxR6HRlkbO/GBGB2FU/De0Qx 2GYyPEv+cGSAKgWPojFSIKsRw3F2itZg6TF3moT4rlSZKtXDt9iO+yPwtSyZE+d4etavDe90Es G4ZRfqnLn/8cOfPRds7IimkFS9ioriYOZTakQJC0tTkPrA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:Mime-Version:Subject:In-Reply-To:Message-ID:To:From:Date: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References; bh=P+6c5GUo+UslhBPaltqYqwdONeZUxGXd3xfaVy5iIKM=; b=E+T+xP5VtZZ9+0p+uyN6mlLZzt MNrgCZJLJBvq8OSR1vgXjwVANXtbXNQsh5jRBhFT4KuUBLQ/KRfF3MdudoDVfSk4eq14rIzwvjKE9 XZX+LhvBkUyDpPoACh66/kyl9ko4Z8/MqX0O4qLqni5W9/pwjJbGtUGiWHbytp5v1jGwdgH2Ruxf9 OA4fvgPM7HINMWbWHXvcvymv1CxwUdo/6vsj8Z8wL2ny+NuDSoS7xSd34dOhC0I3KZffzv8XP47R6 QeP50gsJpYA+Wn1m9bHngbV7SBky1O+Nnoh98Dcl2AtyG85XjCgK5bxjzsVRlOCqQrYwtrrYWf7V8 Z72fUzAw==; Received: by zero.zsh.org with local id 1pO6Nx-0009vY-B6; Sat, 04 Feb 2023 00:26:29 +0000 Authentication-Results: zsh.org; iprev=pass (02d.relay.hey.com) smtp.remote-ip=204.62.114.231; dkim=pass header.d=hey.com header.s=heymail header.a=rsa-sha256; dmarc=pass header.from=hey.com; arc=none Received: from 02d.relay.hey.com ([204.62.114.231]:47935) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1pO6LX-0008iS-1J; Sat, 04 Feb 2023 00:23:59 +0000 Received: from hey.com (bigip-vip-new.rw-ash-int.37signals.com [10.20.0.24]) by 02.relay.hey.com (Postfix) with ESMTPS id CEC511BFF5A; Sat, 4 Feb 2023 00:23:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hey.com; s=heymail; t=1675470238; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to; bh=P+6c5GUo+UslhBPaltqYqwdONeZUxGXd3xfaVy5iIKM=; b=A2fLFELmVh3jpk/SVuzn5bnhBnJACfEZ+v4f5mYURDe0il3WOEpiVaScVM1ctIf/8c504Y Kv3SgMlkVvy9Lo1XMQ8jPMY6jBuVpZ+KlR415AuP+wN/6C16+bu4wgQjSUU/cU/SUVvWFm QGql1BHXD90Jjjo/yY9qUGGLmLorLp3C68TFeTdpT53zxecv33aLAJP9T12QWWbyPb24Bi pTSfrHYbaPmXx8ghSGaklUH4OpaEoXGXedT/LLvDzRyQEObfJYKP23by8+7CioIb18eDRp NPuBZlwYrm30CKY+NxaQXKiT3pF9FnsJOwCgwoyxKKrpr1q6k+nUFchTbF/yzw== Date: Fri, 03 Feb 2023 19:23:57 -0500 From: Eric Nielsen To: "zsh-users@zsh.org" , sergio Message-ID: <2ce01faadd1a08d109681d5e5b04a5849dd7bacf@hey.com> In-Reply-To: <81c93630-34fd-7e2d-39bb-e5f8cc5b344e@outerface.net> Subject: Re: join a string with a parameter value if it's not empy Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="--==_mimepart_63dda59d84702_421d9c3127"; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Seq: 28897 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: ----==_mimepart_63dda59d84702_421d9c3127 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit > p='value' -> result: 'value_string' > p='' -> result: 'string' A variation of your first solution: $p${p:+_}string I don't see how it could be significantly simpler than this. -- Sent with HEY ----==_mimepart_63dda59d84702_421d9c3127 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
> p=3D'value' -> result: 'value_string'
> p=3D'' ->= result: 'string'

A variation of your first solution:

$p${p:+_}string

I don't see how it could be significantly si= mpler than this.

--
Sent with HEY
----==_mimepart_63dda59d84702_421d9c3127--