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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HTML_MESSAGE,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 25417 invoked from network); 16 Sep 2022 00:42:43 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 16 Sep 2022 00:42:43 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1663288963; b=avmFn3J5OUPI2Slco3Ye3c0d5w3q8LI7WQ18ohln9DYv3uvb0c2P5fL9YSkobIvGuOOrR3BhHM 8n2PcPnpMmiXqpht1oGg4zWyto8SUzCBtVShohmqPYnk2qpYbOFeccB6m+1dj7kDmScVRxjJRD r7R15Dop1/vCJLX8AaWgVY5pZbT4Et78+x8GJaGsDLN+F12iYdfpCjGlWH6wDN8MGBF0Ri+IUw i2wSKaKSmLgxXKxKjpIQ+bA0a5O/BCZ9C42pqJxwqFyWHsUGsjO5YoRUQCNxBrZWyXOw2QeCYS x16aOPyMqe9eGXOz5Kr5TROe9s9OxX+J3yX3YcDSVtyRiw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail.velocitynet.com.au) smtp.remote-ip=203.55.137.25; dmarc=none header.from=goldweb.com.au; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1663288963; bh=KJilp8vI1HS+esfnhka7JarhirDShHaVIIfMJhgB21I=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:References:To:Cc:In-Reply-To:Date:Subject:MIME-Version: Content-Type:Message-ID:From:DKIM-Signature; b=q708Jj9BenPEycl3JgMJ7bZ6gjgj2d1BRL1T9KkOK1SIncKuPxDDXnJ+3b1rKuOkrewbVdjgBF iWPpeFGXNir2xk4xbLqJ4BRd4Lpn1kSYUju7HpSgxpnImqcW/jLGlt4g1z1/LAY6yenlZxDYfV sHpAMeaPRvZeA5iJoappHusWD7sMyzfuG5VjJpgd91z6JvV/yJNScAIEFw5z/ntQYB8csWkadk o0rH7mVJACSxvj5u5/I9xQWFH9yrSM1+AH2l88gW5WQ0othermy2t9xYu6ct5Z9lq6BKxq0f0s XPHovUFL7qS+a2x44HjXqtpYHqefS04JhOdGyEL9E3WGqg==; 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:References:To:Cc:In-Reply-To:Date: Subject:Mime-Version:Content-Type:Message-Id:From:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=TmUj8lFPNyLJEW5UuCUze0G6aQHH+Qacls+GaqgCI8w=; b=b5IzTPUuI8SDEHMrazalV6pGlO llHIXoBDRnzGC5G9p52UUjZFW3Ry9MphZxv6MAAe/51YvJf+wUr3jfVcuPgFNkgw72JUSFOPHY1lz 4I6aDtJ+4ewrgSjzb4AfYJlPUbuM70GLFGbqIhiEQqLixg0lvfea8XXPRFpzFhccHRoRZPsjGn2bP 0kjzYTOTXug0BbZyOkbPYOnuicFtFFFUFVoSKtrsG32tQD4Sfr41Y+CtYNR8ybHw9xgM/NBMi61oD cQ8mOULTD7S2Uim0tJpwzFVaPK1x3TsbloyEBu17cAZ1XMjc0LbGfojt+JO9sffu2EaOyufuV+8Lb QF/7a6Nw==; Received: from authenticated user by zero.zsh.org with local id 1oYzRK-000CMk-H9; Fri, 16 Sep 2022 00:42:42 +0000 Authentication-Results: zsh.org; iprev=pass (mail.velocitynet.com.au) smtp.remote-ip=203.55.137.25; dmarc=none header.from=goldweb.com.au; arc=none Received: from mail.velocitynet.com.au ([203.55.137.25]:55656) by zero.zsh.org with esmtp id 1oYzQ5-000Bge-DB; Fri, 16 Sep 2022 00:41:27 +0000 Received: from smtpclient.apple (203-206-23-184.dyn.iinet.net.au [203.206.23.184]) by mail.velocitynet.com.au (Postfix) with ESMTPA id B79A760007; Fri, 16 Sep 2022 10:41:18 +1000 (EST) From: Alex Satrapa Message-Id: <1EF0D745-0597-4C62-9FA0-4D6BDB8F40FC@goldweb.com.au> Content-Type: multipart/alternative; boundary="Apple-Mail=_10869691-4538-4A76-BDB4-4D2DD159B354" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.100.31\)) Subject: Re: Can I test if a parameter expansion has worked Date: Fri, 16 Sep 2022 10:41:18 +1000 In-Reply-To: Cc: Zsh-Users List To: zzapper References: <5dc8b935-f234-ca54-0ceb-50cb1da9bc29@rayninfo.co.uk> X-Mailer: Apple Mail (2.3696.100.31) X-Seq: 28088 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: --Apple-Mail=_10869691-4538-4A76-BDB4-4D2DD159B354 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 On 15 Sep 2022, at 17:34, zzapper wrote: >=20 > I suppose I should be testing the filename before passing it to the = expansion >=20 > if [[ $f =3D~ '.jpg|gif|png|jpeg' ]] ;then echo 'ok' ;else echo 'nok' = ;fi That=E2=80=99s how I=E2=80=99d approach it. Also make sure to check that the new file name doesn=E2=80=99t exist. A = common workaround to trying to name a file the same as an existing file = is to add a numerical suffix. Then you need to check if there=E2=80=99s = already a file/some files with numerical suffixes and figure out what = the next suffix needs to be. One example I saw was to start with N=3D1, = then keep incrementing that counter until file_s_${N} doesn=E2=80=99t = exist. Anyway, if you need help overthinking stuff I=E2=80=99ll be around. Alex --Apple-Mail=_10869691-4538-4A76-BDB4-4D2DD159B354 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 On = 15 Sep 2022, at 17:34, zzapper <zsh@rayninfo.co.uk> wrote:

I suppose I should be testing = the filename before passing it to the expansion

if [[ $f =3D~ = '.jpg|gif|png|jpeg' ]] ;then echo 'ok' ;else echo 'nok' = ;fi

That=E2=80= =99s how I=E2=80=99d approach it.

Also make sure to check that the new = file name doesn=E2=80=99t exist. A common workaround to trying to name a = file the same as an existing file is to add a numerical suffix. Then you = need to check if there=E2=80=99s already a file/some files with = numerical suffixes and figure out what the next suffix needs to be. One = example I saw was to start with N=3D1, then keep incrementing that = counter until file_s_${N} doesn=E2=80=99t exist.

Anyway, if you need help overthinking = stuff I=E2=80=99ll be around.

Alex

= --Apple-Mail=_10869691-4538-4A76-BDB4-4D2DD159B354--