Deutsch   English   Français   Italiano  
<slrnsmtitr.10vf.naddy@lorvorc.mips.inka.de>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!news.misty.com!3.eu.feeder.erje.net!feeder.erje.net!news.szaf.org!inka.de!mips.inka.de!.POSTED.localhost!not-for-mail
From: Christian Weisgerber <naddy@mips.inka.de>
Newsgroups: fr.comp.os.unix
Subject: Re: bash : fonction min
Date: Tue, 19 Oct 2021 13:44:27 -0000 (UTC)
Message-ID: <slrnsmtitr.10vf.naddy@lorvorc.mips.inka.de>
References: <fantome.forums.tDeContes-761FCF.20114318102021@news.free.fr>
 <87k0ia5fn8.fsf@universite-de-strasbourg.fr.invalid>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 19 Oct 2021 13:44:27 -0000 (UTC)
Injection-Info: lorvorc.mips.inka.de; posting-host="localhost:::1";
	logging-data="34617"; mail-complaints-to="usenet@mips.inka.de"
User-Agent: slrn/1.0.3 (FreeBSD)
Bytes: 1527
Lines: 25

On 2021-10-18, Alain Ketterlin <alain@universite-de-strasbourg.fr.invalid> wrote:

> Deux solutions :
>
> 1) if test $X -lt $Y; then ...; else ...; fi

C'est la bonne solution.

> 2) if [[ $X < $Y ]]; then ...; else ...; fi

Ça, c'est faux. '<' compare des chaînes de caractères.
C'est la même chose en test/[ et [[.

Donc :
  if [[ $X -lt $Y ]]; ...

Mais on peut se servir d'une commande arithmétique :
  if (( X < Y )); ...

> La seconde est spécifique à bash.

[[ ... ]] et (( ... )) sont des inventions du ksh.
bash les a copiées.

-- 
Christian "naddy" Weisgerber                          naddy@mips.inka.de