From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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, DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id EA41D2025B for ; Sun, 21 Apr 2024 22:14:35 +0200 (CEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1713730475; b=V9lnsl31tmo9lE/zf8sC7PbZmHYEkZTZ7LW9vmw62qPcAOweFlbLxK7xn7pcox2OwY2+ylpC99 5424VaYWwOYu2w5y/2SPWWqAAtazNorcCcyFE2POfKPhVHu7e+2745ZRNvHSAAxlEK/Xc3lRam X5/dG/zGVufriRnycxFnAkzL880iTrur13kPiK8sy04x7gj+61GpSgCKJ56M1O5UxR/UBaJheS yUkZMVHF8fptwIPue3wYDShdCSl3+v1WN5mmA8KLYaOzycwt9ravAbuZX7EwEsDGyKASjIPoF3 kKJF1TNz1jeUzEh+/qSimVbjahS1pDv9blZOWt90YSQpIg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (relay4-d.mail.gandi.net) smtp.remote-ip=217.70.183.196; 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=1713730475; bh=EDA+xQu/3xbLYBJr262HUzqy8i2BkLNPPnk9ASzRS68=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:DKIM-Signature; b=V8kf3U/kT3YhRWGUey80cRglOyRl0YddFSrfz+UCGTGV5maasc7VZRTs2ov6ziO7exQ7kOPIOF 7DpQj/S2iChC6rhc4iXZ0Kmj8KpaQSr5JQy7sCQfc/D2nXuI7tlEYr54FwIqIYR5h4h6D70Bvc QL2iaRcpbd7yO493GfAFW/b6QXQCaJzPdZyCyvawHG2Pma9J3hvLCxNu2nB7L5CyetxLrJOLdn f0vC7KoU7fdafHM1m78eqP4pcwrUr/UsgcS2oZHM8fEZKOdvXrkWhJgIWoc18WavycGTzirpCc N0l4HMlJlQcBxbhtm9kpKKf/1l1YcoJI9nQztsx14PeHoQ==; 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:In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=ChKJixau0gjgnrzkXRuOVkt9hXu0W+nQCWXLrmC4fZI=; b=kQW2OhfLWlZA7q6/ovgKYJaB7H MUJ2ULtl0/1NA2HBNP3pZt8+aEO+kW1PRHcchfcgZmbwfGefeq6N69faryTLZkpJQQw1IYnTesNED SRMeWAooGCClD+9vQxMMkP/El4RreSsMQTyR4V39NVOLc99sCe5/IQpIQNi9vyzGXG4xUmChoBtnO rXWJcSc+B4Csaunc0RgxhKRiyHlSYntxi6anLMlbhGrYOVaa+VRtkDm7j8KOVWz42zHs/nWcphJAB b9+blSk9NlDMEhaJd0R2BpxNr2MUs5xe/ZfS3RBcoU9ZjS46v1a1ZnzavU1ZdtxY/7k2X07UjagC7 HPYuD2zg==; Received: by zero.zsh.org with local id 1ryda5-0004zW-V5; Sun, 21 Apr 2024 20:14:33 +0000 Authentication-Results: zsh.org; iprev=pass (relay4-d.mail.gandi.net) smtp.remote-ip=217.70.183.196; dmarc=none header.from=chazelas.org; arc=none Received: from relay4-d.mail.gandi.net ([217.70.183.196]:41219) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1rydZR-0004Fz-M5; Sun, 21 Apr 2024 20:13:55 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 2F577E0002; Sun, 21 Apr 2024 20:13:51 +0000 (UTC) Date: Sun, 21 Apr 2024 21:13:51 +0100 From: Stephane Chazelas To: Roman Perepelitsa Cc: Ray Andrews , zsh-users@zsh.org Subject: Re: optimal expansions? Message-ID: <20240421201351.n5cku2gqf246joaf@chazelas.org> Mail-Followup-To: Roman Perepelitsa , Ray Andrews , zsh-users@zsh.org References: <53fab6be-26d7-4de5-844f-ffc295d9a494@eastlink.ca> <3d15311d-b5fa-4a55-a17e-e61fcdded7d0@eastlink.ca> <9fe68299-c89f-46a1-b10f-eefadd03a262@eastlink.ca> <20240421161440.jicmznwxqb6pz2fg@chazelas.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-GND-Sasl: stephane@chazelas.org X-Seq: 29854 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: 2024-04-21 19:39:20 +0200, Roman Perepelitsa: [...] > I'm curious. Which of these would you use? > > print rebooting > print -r -- rebooting Probably print -u2 rebooting, though in scripts, I usually define functions for reporting like: info warn err() print -ru2 -C1 -- "$@" die() { err "$@"; exit 1; } info rebooting In any case, for fixed strings, whether to use -- (or - which also works for print) or not is not relevant as long as the string doesn't start with "-" (or "+" for some commands). Same for -r as longer as arguments don't contain backslashes. The -- is needed when arguments are not known at code writing time (or are known to be a problem). > Or these: > > ls ~ > ls -- ~ > > I prefer the first form in both of these examples, whether in scripts > or interactively. It's less code, so less time to read and understand. [...] Strictly speaking, it should be ls -- ~ as ~ expands to $HOME which we can't guarantee won't start with - (though $HOME starting with - would only happen in pathological cases). -- Stephane