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.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,NICE_REPLY_A,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 1625 invoked from network); 15 Sep 2022 08:50:25 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 15 Sep 2022 08:50:25 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1663231825; b=VIEPHM0Wph+sNztGl0epghKs4gehI2QN8Q/LCbz119CHWmXJC3QTzBdofendtD2VRfQH14GFOl CZb0dG1BdbTtV+btpi61me6TwRKPgPBQpPfpSAXEK9tEo20KtEPYjvDr29fe2yGsNOesmw/Uvm qCQO2oVYkpbKqsu7OpXVl+Z5WLROmGXasml+62rVrX1FLObJ9fDbKXOqcUPrOBw+3D8uOETVOx v/nYk4IbVZ5kgRv711OW063AavC1Cx/JULL41MkGvzymDYo0DA8o5/yUsLbPGStPNiJvwl2KkE KoSrJTGlTe1ZdVRxImAvcEztpjYDyJWmtMnR7g6NAxEzEQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (p3plsmtp22-05-2.prod.phx3.secureserver.net) smtp.remote-ip=68.178.252.62; dmarc=none header.from=rayninfo.co.uk; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1663231825; bh=Toetn41aGmYbukH/QW2gRhhFxDHNMOHhJXCkYvmvc/8=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:To:Subject:MIME-Version:Date:Message-ID:DKIM-Signature; b=eBXIKXf8GWthQupqW8f70g36mfZwmjjMfV9lA62stp7Cweg9hpdF7LWZCVuDjo9aXaRx6sBfYL 8g8Ct6o3h6xjhPk/vk5fNHJh79dKxZwQM59ls6jeNMNrwRer4YM9SG7b75o2BF5+XNiCp0saT4 J1Se2SWRGZN9sUYrfMWnFdmouNXw0oSQnvVEgN5VFBLziFzrYaHhj0kYJuZBYOGwNK7JXyPnN2 gZ9kmLM7n4mJ9/lcMrOhsSlrvbU8Ergjk7gUoYhNO2tA9i6H+jnqZ4CTT1c22eQs1+LxfAINJC 01/Ryow5HtDuCHJEEuAE23NWZvDEhfR3RkVy6SXYiy18Ng==; 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:In-Reply-To:From:References:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=XZDnnxdeu+WXCrIttCsjQ44X0OKZO59Fo7OnywPGtLw=; b=DDwpmj63Ti4rIgkDcgHs9wT9y9 OEJSk+hZ1WZcAZlvqfFDc5vpOq837YA64G4V2BcfI2Swvm4+J6M173+NYrdTpwXoDf0PvfKWCKYhS CGMlvzNlCL41d+//mPwiaelQtRB4BudWkVLitLxBKMf9w5MX1a8nGT8EqX8HC2l41L9Xgm+lgCh1z 11DkigVYBtofuV9IZ5N102ygSAwHVHpUN9FxFomHhsE98BEn9jhZl7GMAPtfTdJ7CVBs3Wy1OkhJ+ baFt9mpbmHjRizPz7xvH++i6k3CxHYIf7Ogmfk1+xpYf4yonPRY4FKBnq5JOt+KHYL9QlJM9DLEWG 53b2tVtA==; Received: from authenticated user by zero.zsh.org with local id 1oYkZk-0007j9-Kc; Thu, 15 Sep 2022 08:50:24 +0000 Authentication-Results: zsh.org; iprev=pass (p3plsmtp22-05-2.prod.phx3.secureserver.net) smtp.remote-ip=68.178.252.62; dmarc=none header.from=rayninfo.co.uk; arc=none Received: from p3plsmtp22-05-2.prod.phx3.secureserver.net ([68.178.252.62]:56252 helo=p3plwbeout22-05.prod.phx3.secureserver.net) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1oYkO5-0006jk-6O; Thu, 15 Sep 2022 08:38:22 +0000 Received: from mailex.mailcore.me ([94.136.40.142]) by :WBEOUT: with ESMTP id YkO2ooJKjY4psYkO3oPmq0; Thu, 15 Sep 2022 01:38:19 -0700 X-CMAE-Analysis: v=2.4 cv=fokZ2H0f c=1 sm=1 tr=0 ts=6322e47b a=s1hRAmXuQnGNrIj+3lWWVA==:117 a=UNgyr3XT6yv5NrNUVILU/Q==:17 a=1HjCxttUbyEA:10 a=IkcTkHD0fZMA:10 a=xOM3xZuef0cA:10 a=22Ro6XbQAAAA:8 a=lernSqPwYK1pvgSoiMcA:9 a=QEXdDO2ut3YA:10 a=p1RiBf0vZFgkX3Jmbd9N:22 X-SECURESERVER-ACCT: david@rayninfo.co.uk X-SID: YkO2ooJKjY4ps Received: from [95.145.222.232] (helo=[192.168.1.231]) by smtp03.mailcore.me with esmtpa (Exim 4.94.2) (envelope-from ) id 1oYkO1-0004cW-UQ for zsh-users@zsh.org; Thu, 15 Sep 2022 09:38:18 +0100 Message-ID: Date: Thu, 15 Sep 2022 09:38:17 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: Can I test if a parameter expansion has worked Content-Language: en-US To: zsh-users@zsh.org References: <5dc8b935-f234-ca54-0ceb-50cb1da9bc29@rayninfo.co.uk> <1026093540.752006.1663230255721@mail.virginmedia.com> From: zzapper In-Reply-To: <1026093540.752006.1663230255721@mail.virginmedia.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Mailcore-Auth: 8308408 X-Mailcore-Domain: 840527 X-123-reg-Authenticated: david@rayninfo.co.uk X-Originating-IP: 95.145.222.232 X-CMAE-Envelope: MS4xfDYjTUWp8wD4+LPboV5otYrpTn1X93rms5uxHiSloObmkxivMgDnmtOQ88a1oxoF7VkYu/3yA4pXWfvCmuLGSsq/b1Ksexx1U6qvPm92+7+c0kSMg25a Y8+XEIz23dVjslhG9mwT+JfiFVuF0IW/VkYMKGjElqypGEyUwP2blze6sRvT/Kq8mkkNk0ZZ/ksUCA== X-Seq: 28082 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: On 15/09/2022 09:24, Peter Stephenson wrote: >> On 15/09/2022 08:34 zzapper wrote: >> # adding a prefix '_s' to an image name >> >> f=stuff.jpg; >> >> print ${f/%(#m).[pjg][npi]e#[gf]/_s$MATCH} >> >> stuff_s.jpg  # good this is what i want >> >> # now pass 'bad' input >> >> f=stuff.txt; >> >> print ${f/%(#m).[pjg][npi]e#[gf]/_s$MATCH} >> stuff.txt  #  expansion has obviously left the input unchanged but can I >> test for that??? > No, there's no way of telling if some expansion actually changed an > expression without actually testing the final result. The differences > between the cases (changed / not changed) are buried deep within the > shell and don't leave an obvious trace above --- and in any case given > how complicated zsh expressions can get finding a useful binary way of > testing what the whole expression did would be incredibly hairy. > > Just test the resulting expression. > > pws > I now realise that it would horribly subjective to decide whether or not an expansion had succeeded in any case :) f=pws echo ${f/%(#m)pws/thanks $MATCH} zzapper