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, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 8487 invoked from network); 1 Jun 2023 18:24:05 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 1 Jun 2023 18:24:05 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1685643845; b=YivcjEIDELGDtHfqSMv2MNkpGQUEpv46IYC707I3M3h4HH2gAlReLv1eCafdSEMbuN+rr1FzgX b6mjnwEIgpZPWj6UIoM7BQ5uHQ4yKLFYKxvoSUzlbyI0sBpR6qVAzJhmCM4BCtS+6M/em2xpvB +Xv8iay5lBLdGsIeFV/mB5bkmh7YMigF5toeSOqDej1w/soFVN99LzMaM30sLMh0kL11LTepD6 VgfWODMl0D+X4GMeJWxQlRInvPFbTGwRxGJ4nBUIGDpgu9UTRpKH3Uw2OPuw6oEBXnaVuCellN MgjIx19tov7yfuh8Ru5aC8dOXrIvF5ML6CmRxBy5dHC6QA==; 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=1685643845; bh=6DCwdC41Vp/owWlLajyfqXeBYKSNUafEroj/Ez16tpk=; 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=Vh8PqSdZxRRHMN//byasCcDz2uNM0hpxq9EUa8pUIioH4nLOxGt5YLjjaRilSc5EDHGGl3z8Ac oYorB0k18NJQ+DPttzgX0ZnkpFPAqbq/GWsaQB/hpGr+FwojFzpU2kT9dZALiux2hUWgGMD9NI UzNghvsQ6IruNZxoWrYA7JG001sFFs3vQZ7HpSc59CrpgEQq2Z5KGHvA/Pw4yBGYeKKEfaNqJh 05Cp5szD+vrz7c/Cmbe5ehTH/fXd0wpoQ3MdgBOOhAv16tpO/tf8FitSO0nab53omRKjwmSuRH 2RswgNV+kR+6+R/sQOYVJXRjqz70l+8rB2xCnfn8jqkKBA==; 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=yM7GrpqoQvcdeb0FDL4zSGrKMDeQyg2K+7g76ZSdD9E=; b=eTZTqGP2pRxykjgn12wtITlA8G oU0hWEG0ESXL1wNLNG+d9pSw7xYD/MXaI8dRS1X8HpPJBCRNvBtXTgAZOk71a0TVnPkfisyaiUVvE I8xxEnCQw3uOzgq2hmo8ODByGwcVMPD9zV8WvfKtByV/61qXtuWArFh6zEy1LDPknkc4j22nH8Gva af5Fi/Arkeop9xl4aP4D9wHGREz7C50Hcm6xnqHfnFY0wskXVubxiB9uh9cFAwv27bd65VFGWLz6F lF9SrQXj3bjFmZTf7PFyP37C/apiCgzHbMN/yaSrkyt0tUxqJwjG9I/HknKdaJdsbvKNOj4OM9j7x dawMt6dg==; Received: by zero.zsh.org with local id 1q4mxw-000Awk-Fi; Thu, 01 Jun 2023 18:24:04 +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]:33309) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1q4mxJ-000Acs-Qi; Thu, 01 Jun 2023 18:23:26 +0000 X-GND-Sasl: stephane@chazelas.org X-GND-Sasl: stephane@chazelas.org Received: by mail.gandi.net (Postfix) with ESMTPSA id 0B7F0E0003; Thu, 1 Jun 2023 18:23:24 +0000 (UTC) Date: Thu, 1 Jun 2023 19:23:24 +0100 From: Stephane Chazelas To: Mikael Magnusson Cc: Zsh hackers list Subject: [PATCHv2] is-at-least compares zsh's version if $2 is provided but empty Message-ID: <20230601182324.6m4fab26brkyxvcq@chazelas.org> Mail-Followup-To: Mikael Magnusson , Zsh hackers list References: <20230528113907.hvxjuu4wwmettr5p@chazelas.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Seq: 51813 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: 2023-05-28 17:51:49 +0200, Mikael Magnusson: [...] > This requires more changes to be useful: > % is-at-least 1.9 ''; echo $? > 1 > % is-at-least 0.9 ''; echo $? > 0 [...] Well spotted. I can't say I completely follow the logic in the function, but those corner cases are probably better special-cased. diff --git a/Functions/Misc/is-at-least b/Functions/Misc/is-at-least index d4ff3552a..5985684be 100644 --- a/Functions/Misc/is-at-least +++ b/Functions/Misc/is-at-least @@ -24,8 +24,14 @@ emulate -L zsh local IFS=".-" min_cnt=0 ver_cnt=0 part min_ver version order +: ${2=$ZSH_VERSION} + +# sort out the easy corner cases first +[[ $1 = $2 ]] && return 0 # same version +[[ -n $2 ]] || return 1 # no version + min_ver=(${=1}) -version=(${=2:-$ZSH_VERSION} 0) +version=(${=2} 0) while (( $min_cnt <= ${#min_ver} )); do while [[ "$part" != <-> ]]; do