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.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 29110 invoked from network); 23 Oct 2023 17:05:24 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 23 Oct 2023 17:05:24 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1698080724; b=NTBH4WY4cc+yI1Mht1LJfrFZKHrhu1Zax8xajNn85crQhcE1oTz7eGiak+61ZCLaytH5juIjXr m8fJw7DGvBq4GEmrwDv4FeW2Elp+rdKLYyzBMk5zfDyyBAkKDaKBPVejY/Si8vFz4IcOe2tnkG Fcb3dRnqQKDINxoRxqS/4Notp4q+Q7gB/xakRanfBts7td/CorH/hKjIBCe9O9AnFfzL5sd6km zPHAqf+VKzj/cFKxuYpUitZ76X5Y107+tolpIF8hInfUQqQdAsx3tMkx3mGtrkDdB6BEClS0fJ LTkK2H4P0X82GiZSzla1+gauww0kv6LsPEKnKpXhYkygGQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lj1-f169.google.com) smtp.remote-ip=209.85.208.169; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1698080724; bh=Fb+b8E6TRzwvTbXP3VR8kJvaQBY91v0rVOj8I+++y3w=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature: DKIM-Signature; b=IHJvc2IYJv4eeJqNOuB7d7ZrIy7hedsj/pjTk54wnx1h9uFZT3jYI7clCFeGK0p8rMB9cV+kMo IatSFN8vZrMLaupwSDXccFC+q4Tq5dUR17lOWsxpfsQFIHW4qFXLeuxvUxWnMFJTm0tNLylzAG f5R8WVrfWI51Lt+bmVklEI92zqXwuV6yrkZ17wtFm2hZ5yqLNlsZkExfKJ7UQCNOXLScKvYIzd rZuFnS+x3mnJrn7/ZyqgwOTOnUFTSabEJaH/BOrHP3nJbEMrbtF5hY2yKMIvFIF8v9+I06eV08 8mf7m00FaiCLPXrEq7Pv64npgmczqaGrUJGWYKnbb0vw8w==; 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:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=ya9Y0+fcwVik4p5iOLqFjgJum15M+y5qKCLcDRxL8CU=; b=eiMMqjHHrsRBohnCnEzRPliM7Z vLNf/7hKJExzfima9GbHPIETWkxZaBOrMgN9oivigfcS6h5TWN9PUwxrdIvk67MkT4/Gr6ewuIWG2 zH98a+b91TefGYowwqPTdxqTcdK+ej5VlcjSCeOipf8jlmQlUV08ZS0bTtSXNNV0WP4AgpKPx27P6 GtLC7ajuRvgaP7kYGq/LyKMgqIZAIK8mLz0aH/xNeI1JurkuLDSQ3mL9LeJj1rB8jfgHnJK0gtBJY hXxE2Ze50K75ugNtxrkTV3nIzMCm1wmdWVYTn2blf0toav0G3PPHwoemZNRFJV1U7CTd0mW8dTvKw KM+qWdJQ==; Received: by zero.zsh.org with local id 1quyMl-000M1n-Lw; Mon, 23 Oct 2023 17:05:23 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lj1-f169.google.com) smtp.remote-ip=209.85.208.169; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-lj1-f169.google.com ([209.85.208.169]:43442) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1quyKm-000LHr-GU; Mon, 23 Oct 2023 17:03:23 +0000 Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2c51682fddeso51631291fa.1 for ; Mon, 23 Oct 2023 10:03:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698080600; x=1698685400; darn=zsh.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ya9Y0+fcwVik4p5iOLqFjgJum15M+y5qKCLcDRxL8CU=; b=LxOxGe8BL3R8YoMk7heul7ybP9gJj05oB0lBSvq/N27EtZez2iqA9WiVElIR6ZfDgB 5j/3ClQMjU9jBOF0F7Nkm4GLNTJjNiBspXc1QSh/kMhR14vpwqaR4PgZmNbIbMY654zF Kyjkdpe2WK9oTZld7h8UhCBEl91SlDN6jJ8KogwPOsNKjtnLpb+bqcIfUdB7BTxCusqN IvCMhZM3VqqoZnvVpeC225bz29MAm2bgiUTl2YSiJ7iraF3xB6pVNMTyj7AqszN1KE/k dGKUY5TDsoqNbdULCL4ZrLshXdxOFa+33aBFRwxfY01noFrCXShKZKC0bwkluW8uG49U JV6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698080600; x=1698685400; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ya9Y0+fcwVik4p5iOLqFjgJum15M+y5qKCLcDRxL8CU=; b=WqMCEu/rIrvg0GlOV4tKNklyDR3vDFF5Yfnt1tnJtOZU9b/2Uv6BcTvHiKBQQ5IXXB WsqKzU636JwORSYdp1N2qn9jvToOsTEsTkaCxlFprUgkknoifeT6mR/b/D3IcQW6Tp/9 dq7L6ntXUNetRllDMfg0PD46x/UbTIv8xhoZVuKlEdOTJ4gb3H0WvsJqnCGrz1z0vn1q ibQIJNkFJN0NxzwiXL1uA+qqaWHqu1Vedi1sZo8QcpHNNCfaspcByW2+Zg5RJeyn8+jZ jdisk/c2LeFX++GECCalc7yYrIXYPi2fzlIatUh8Iz87FD09G/njYs85JTJ6AlB/EdZ2 OClg== X-Gm-Message-State: AOJu0Yw/Xb2YYwX9X7YCGV0QxnniruZJdgDErJElF1Ax5Ly+hAYJwlLW TUrOAh7zzIbOEE+I66EGnF6kuyloq52xosilVCzpHg5TWbY= X-Google-Smtp-Source: AGHT+IGVVZ995H1nOi32Sr2jNE45yXPPcj4EoUF9XSTQ6eeJ2ZieTtRIjtWwiGUdH7/wLbXH8JmEeD70XnqDJN+zJfw= X-Received: by 2002:a05:651c:49a:b0:2c1:7df1:14b1 with SMTP id s26-20020a05651c049a00b002c17df114b1mr2788479ljc.15.1698080599591; Mon, 23 Oct 2023 10:03:19 -0700 (PDT) MIME-Version: 1.0 References: <1372623164.1448847.1698079437641@mail.virginmedia.com> In-Reply-To: <1372623164.1448847.1698079437641@mail.virginmedia.com> From: Roman Perepelitsa Date: Mon, 23 Oct 2023 19:03:08 +0200 Message-ID: Subject: Re: Variable fails to increment with lvalue error To: Peter Stephenson , Evan Clearfield Cc: zsh-users@zsh.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 29316 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 Mon, Oct 23, 2023 at 6:44=E2=80=AFPM Peter Stephenson wrote: > > > On 23/10/2023 16:33 Roman Perepelitsa wro= te: > > On Mon, Oct 23, 2023 at 5:28=E2=80=AFPM Evan Clearfield wrote: > > > > > > I then increment it with a simple call =E2=80=9C(($count++))=E2=80=9D= , and when I run the script, I receive the error =E2=80=9Cbad math expressi= on: lvalue required=E2=80=9D > > > > `$count` expands to `0`, so `(($count++))` is equivalent to `((0++))`. > > Is it worth drawing attention to this, or is this just excess verbiage? > > pws > > diff --git a/Doc/Zsh/arith.yo b/Doc/Zsh/arith.yo > index bc3e35ad5..e6380b2cb 100644 > --- a/Doc/Zsh/arith.yo > +++ b/Doc/Zsh/arith.yo > @@ -23,8 +23,10 @@ command which begins with a `tt(LPAR()LPAR())', all th= e characters until a > matching `tt(RPAR()RPAR())' are treated as a double-quoted expression an= d > arithmetic expansion performed as for an argument of tt(let). More > precisely, `tt(LPAR()LPAR())var(...)tt(RPAR()RPAR())' is equivalent to > -`tt(let ")var(...)tt(")'. The return status is 0 if the arithmetic valu= e > -of the expression is non-zero, 1 if it is zero, and 2 if an error occurr= ed. > +`tt(let ")var(...)tt(")': note the presence of double quotes, so that va= riable > +expansion etc. takes place before arithmetic evaluation. The return > +status is 0 if the arithmetic value of the expression is non-zero, 1 if > +it is zero, and 2 if an error occurred. > > For example, the following statement > > @@ -37,6 +39,10 @@ example(let "val =3D 2 + 1") > both assigning the value 3 to the shell variable tt(val) and returning a > zero status. > > +Note further that it would be incorrect to replace tt(val) with tt($val) > +as the latter is affected by double quote substitution, so that > +arithmetic evaluation does not see the name of the variable. > + > cindex(arithmetic base) > cindex(bases, in arithmetic) > Integers can be in bases other than 10. > Let's ask the OP if this would've been helpful. Evan, have you read this documentation page? It's available at `man zshmisc` and online at https://zsh.sourceforge.io/Doc/Release/Arithmetic-Evaluation.html. If you have, would it have helped if the docs were amended as per Peter's patch? Roman.