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.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SUBJ_DOLLARS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 2710 invoked from network); 20 Sep 2022 13:19:11 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 20 Sep 2022 13:19:11 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1663679951; b=H7c6LlDP2tMwyQ7c1naRoUiH14nzcyZFTKIi142UqPaWIlCJ2puiq+SYFRaPJRBgmDu29pqJda KrhRdGg2scYhx2sMRUIUWKOk7+iji2zSIJqAyU0i9MSt7n2UZHkN0QKW/SbkBFGhoXxQ0BMwZZ xKwZNC/oaykouH7eTxi5LHGgfOds02OHt21IR5hCFh6mdTa8zSYBN2BU9yeVnV1zfMI2A2CJsH jPJs1J1XDe3pLHHl8dQtX+fu09QmEYPRwMedZygNnARZFKDjzGlY4hOHd2Qwyy1s/ac9bJjFhe dV/jQAFan+DPNoKG1rCAUmEUECmUPTPAjG18r3/nyWu01A==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (relay5-d.mail.gandi.net) smtp.remote-ip=217.70.183.197; dmarc=none header.from=chazelas.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1663679951; bh=JCq7xFrukbaVTAh2gBpkMFGUY0pYdoZlgfWi3IDZLa0=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:MIME-Version:Message-ID:Subject:To:From:Date: DKIM-Signature; b=Z7nMEt9MAeLx5g9+HONqEVZEKahuQee8UJ3mA9Mr3AZht3bIluF8/pEL4pNsFyFI0kMQAs6r/l 6zJuEfC4VFQpMnsPWeztUOTjrz+Ay2Dc0Vdxn7X3WBbxUK3Ov7SF3Iflstb6QaY94/B03+21l6 3sW9TJCfMWshuNPcq2lI9/DJGa2a+rH77VR2eZUXvZ9ajj2eI+x194jT9qf+ueDXczgPvyIdpA w9KbwiEtJsDudueQdqehB9a9gJJtvwnOihoxhObAKc7ylG0xUn0wPu23vbrkcKGxXxtSlR8UDm NEIXR4YZL5aVOs8icx75ip6Kg3rB0DqVuglIaa9nZ/Gi/A==; 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-Type:MIME-Version:Message-ID: Subject:To:From:Date:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=/S0LdhtpD+5+UWVoCdGVS4+Zi8hyFaBdE2eaGi5YX94=; b=lAu13OxA3cOdpZeL/50W4djto8 2caggvf67spvwElESGGmptTlI1bY6u18IOJsT7tNDNcPKXXNp7mW6+/VH1OCkkxITeBOWISZTIjN4 BCpaYFyUt03sJRqAZ34jIdoCPq5D4+/ngDSn5U3v3JDIM3XAekiY2PUZzuGEDoBwm6Puxf+tyRjXy KmV0sntHvg4wjJRs5X5b3APYiNWC6xPzvLmJwqo0O7YUxV5Pi24yUeqgX1kQehkUSVP/hrgcqmODv E+gXjDM1Hz5n0GG9q5OF1/k0KW646epHuwDXEMUuDxhHkBCnz7Q7S8mfT5yzXf6zw74aSJIwTcd7h VBd+uEcA==; Received: from authenticated user by zero.zsh.org with local id 1oad9a-00052V-H6; Tue, 20 Sep 2022 13:19:10 +0000 Authentication-Results: zsh.org; iprev=pass (relay5-d.mail.gandi.net) smtp.remote-ip=217.70.183.197; dmarc=none header.from=chazelas.org; arc=none Received: from relay5-d.mail.gandi.net ([217.70.183.197]:33515) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1oad9I-0004ep-L5; Tue, 20 Sep 2022 13:18:53 +0000 Received: (Authenticated sender: stephane@chazelas.org) by mail.gandi.net (Postfix) with ESMTPSA id 020A51C0010 for ; Tue, 20 Sep 2022 13:18:51 +0000 (UTC) Date: Tue, 20 Sep 2022 14:18:51 +0100 From: Stephane Chazelas To: Zsh hackers list Subject: $0 (or argv[0]) not used in error messages in zsh -c inlinescripts Message-ID: <20220920131851.3rc27t4cfhwxchay@chazelas.org> Mail-Followup-To: Zsh hackers list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Seq: 50652 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: (minor) $ zsh -uc 'echo $0; :>/; 0=foo; $1' myinlinescript myinlinescript zsh:1: is a directory: / zsh:1: 1: parameter not set I expected: myinlinescript myinlinescript:1: is a directory: / foo:1: 1: parameter not set Like most other Bourne-like shells (except yash) do (except for the assignment to $0 which none other supports). Isn't it the whole point of being able to specify $0, so it's treated as the script's name when using zsh -c? Note that the interpreter's argv[0] is always ignored in any case. $ ARGV0=foo zsh -uc 'echo $0; :>/; $1' foo zsh:1: is a directory: / zsh:1: 1: parameter not set Also applies to: $ ARGV0=foo zsh -u <<< 'echo $0; :>/; 0=bar; $1' foo zsh: is a directory: / zsh: 1: parameter not set Modifications to $0 are honoured in: $ zsh <(<<<'echo "$0"; :>/; 0=foo; :>/') /proc/self/fd/11 /proc/self/fd/11:1: is a directory: / foo:1: is a directory: / Not in: $ zsh -c '. $1' foobar =(<<<'echo $0; :>/; 0=foo; :>/') /tmp/zshl53EOM /tmp/zshl53EOM:1: is a directory: / /tmp/zshl53EOM:1: is a directory: / See also: $ zsh -c 'f() { echo $0; :>/; 0=foo; :>/; }; f' f f: is a directory: / f: is a directory: / (modified $0 not used in error message). -- Stephane