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,HTML_MESSAGE, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE 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 BAA9629879 for ; Sun, 4 Feb 2024 16:52:30 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1707061950; b=XrVRRjhg4my17Tdb+gyOPCTUg1dAGx8GAE4ofmKJjiUA8EQhoxPVqcjvGf9nvCTlnBp9uxNTCT A/eGOk+EkwGAl0Fsn05FLrH214q4TIl1OyjLpT7rfv/8LBUFA2Ab1Bc9ajOqL7XBq8biCKHDaP nbeRQpaHnWcIGNESiXC1S/forreVMtsSsS85HKqeHtMMAtJNEahw5Z2RZ/blMKZr+ldK7c5o1z XG9HSA0MS5ePuAWOsmFapGc+hd/lK//OFv8eOsLEehB/zdMIHIJgACsnF3pv7uCiZnkK2ibPwD 1jTuqtG6siI/ABV4L2w5xUK79cGr3+jfrlGg1BGKqSMPoA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mta01.eastlink.ca) smtp.remote-ip=24.224.136.30; dmarc=none header.from=eastlink.ca; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1707061950; bh=4RIsFZ2glB09n3WlJZFLCOxe+wHwPEomQ08TdKDqbh0=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:From:References:To:Subject:MIME-Version:Date: Message-ID:Content-Type:DKIM-Signature; b=Y7+PPFVsfb0MUMZ/aEmCWfckXxqlBIKyEDWk1WSJ8CmDJodgdGnG1JQRxScjOeOTFBotAs/FlW Qty0tSnF+l1E9AoByBcb6bVFoGFNel11rx2RH6bwB7bkF8M6a1+LZwySjVRmvqHQhIGkrua2F+ VLWmyFum7IGPwZWXsU48tFyKX2aTAacfyxEJ7QH5TlPjAo2k3Rg0LZZNB6Y/jS6f759wXOKspQ gmHmPjmB5VJudJ7nh196tt7d9f5OZtLDubNZr4WrdbFuvTGxMEpOIisY5ckF74VoWGOSA7CgqZ Kv2/XtfbP32EK73lFPU/gS2ld0rDXLsawgjPM1ZOFxl2Ag==; 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:From:References:To: Subject:MIME-version:Date:Message-id:Content-type:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=EdbhhWlR82pDhlDlLZqDWld10PVX+ZvqKH1UlwE4VLs=; b=nV4zHC0Nbt/Wzyr0C8BS/mCMtg DUOs2D7uAKW4qdnxcuYm2WGQHxEBNo5dMmmC0LDHsnL6DdPa1ygXt1ZNlsVvuL6JFiXhEU3xMR/KU UndNkuy6vapZNaBp8IHz3mcfzRa5IDm83J0DcfzziBeTmh5PHWkaXj4PBZ+m/FB1liyhJ2Rux4RTs jgxNB5j43iXqntN4ebG7MIPgBuF0hdjONveIM2dUHd7UrIMrdDS26YxC+W4YvX0bckNuq6PjQXnat PZhkCSipbd1i3M1nR6jWFDJM66mhVVf5oSdzuEFmiCf2kr0L8OSQK/9owY5x6d65Tju6etSaIdimD OGfKkYKQ==; Received: by zero.zsh.org with local id 1rWenG-000HJh-64; Sun, 04 Feb 2024 15:52:30 +0000 Authentication-Results: zsh.org; iprev=pass (mta01.eastlink.ca) smtp.remote-ip=24.224.136.30; dmarc=none header.from=eastlink.ca; arc=none Received: from mta01.eastlink.ca ([24.224.136.30]:32777) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rWemk-000Gb4-3F; Sun, 04 Feb 2024 15:51:59 +0000 Received: from csp01.eastlink.ca ([71.7.199.166]) by mta01.eastlink.ca ([24.224.136.30]) with ESMTPS id <0S8C2FGMR98O6O01@mta01.eastlink.ca> for zsh-users@zsh.org; Sun, 04 Feb 2024 11:51:56 -0400 (AST) Received: from [192.168.0.11] (host-24-207-19-13.public.eastlink.ca [24.207.19.13]) by csp01.eastlink.ca ([71.7.199.166]) with ESMTPSA id WemhrDGL8uLJ9WemirH9kX (version=TLSv1_2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256); Sun, 04 Feb 2024 11:51:56 -0400 X-Authority-Analysis: v=2.4 cv=PZtchThd c=1 sm=1 tr=0 ts=65bfb29c a=e7T7DzMKK1R988ZCg0wLyw==:117 a=e7T7DzMKK1R988ZCg0wLyw==:17 a=r77TgQKjGQsHNAKrUKIA:9 a=6QF-HOIEPcWOuAFBvMwA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=ZLGELXoPAAAA:8 a=1s3KcqPljvKlK5ZjiwgA:9 a=MoTksaRJSl8lWBSw:21 a=_W_S_7VecoQA:10 a=CFiPc5v16LZhaT-MVE1c:22 X-Vade-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrfedukedgkeduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecugfetuffvnffkpffmpdfqfgfvnecuuegrihhlohhuthemuceftddtnecunecujfgurheptgfkffggfgfuvfhfhfgjsegrtderredtvdejnecuhfhrohhmpeftrgihucetnhgurhgvfihsuceorhgrhigrnhgurhgvfihssegvrghsthhlihhnkhdrtggrqeenucggtffrrghtthgvrhhnpefhteethfevgeeuvdelgefgvdevudefueduffdvgfelvddvgfdtieegueeuleeifeenucfkphepvdegrddvtdejrdduledrudefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdegrddvtdejrdduledrudefpdhhvghloheplgduledvrdduieekrddtrdduudgnpdhmrghilhhfrhhomheprhgrhigrnhgurhgvfihssegvrghsthhlihhnkhdrtggrpdhnsggprhgtphhtthhopedvpdhrtghpthhtohepreerpdhrtghpthhtohepiihshhdquhhsvghrshesiihshhdrohhrghdpghgvthdqkghiphfrrghsshifugepthhruhgv X-Vade-Score: 0 X-Vade-State: 0 X-EL-AUTH: rayandrews@eastlink.ca Content-type: multipart/alternative; boundary="------------kNtDSMCgvWO8ZyGpCsFgDo6s" Message-id: Date: Sun, 4 Feb 2024 07:51:55 -0800 MIME-version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: for loop 'bad math expression' Content-language: en-US To: zsh-users@zsh.org References: <4c14e191-0605-4492-9f67-9a5b35ef132b@eastlink.ca> <4da0eeb4-4589-4c5d-9b89-a1a22209e18e@eastlink.ca> <7ccf5b82-a37d-47b5-a700-fb1096ab495c@eastlink.ca> <0875ffd7-e3a4-4ddc-9c4b-47e2c593ea4c@eastlink.ca> From: Ray Andrews In-reply-to: X-Seq: 29626 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: This is a multi-part message in MIME format. --------------kNtDSMCgvWO8ZyGpCsFgDo6s Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2024-02-03 18:05, Lawrence Velázquez wrote: > % var=abc > > % unset abc > % print -- $((var)) > 0 > > % abc=1 > % print -- $((var)) > 1 > > % abc=1+1 > % typeset -p abc > typeset abc=1+1 > % print -- $((var)) > 2 > > % abc='1.0 * PPID / SECONDS - RANDOM' > % typeset -p abc > typeset abc='1.0 * PPID / SECONDS - RANDOM' > % print -- $((var)) > -10080.313725490196 > That astonishes me.  I've never heard of any such thing.  Nobody tells you these things. % var=abc; print -- $var abc % abc=1; print -- $((var)) 1 # abc was a string, now it's the name of an integer: % let abc+=3; print -- $((var)) 3 # var still wants to be scalar: % var+=3; print -- $var abc3 # So once var has been touched directly the link to abc is broken: % abc+=2; print -- $((var)) 0 % abc=2; print -- $((var)) 0 ... I suppose there's a good reason for it, but that leaves me dumbfounded. % Sonnet_1='From_fairest_flowers_we_desire_increase'; print -- $Sonnet_1 From_fairest_flowers_we_desire_increase % From_fairest_flowers_we_desire_increase=1 % print -- $((Sonnet_1)) 1 ... ok ... Anyway, the lesson is just not to assign a glob expansion to an integer.  Never, ever.  Sorry for the trouble gentlemen. --------------kNtDSMCgvWO8ZyGpCsFgDo6s Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

On 2024-02-03 18:05, Lawrence Velázquez wrote:
	% var=abc

	% unset abc
	% print -- $((var))
	0

	% abc=1
	% print -- $((var))
	1

	% abc=1+1
	% typeset -p abc
	typeset abc=1+1
	% print -- $((var))
	2

	% abc='1.0 * PPID / SECONDS - RANDOM'
	% typeset -p abc
	typeset abc='1.0 * PPID / SECONDS - RANDOM'
	% print -- $((var))
	-10080.313725490196


That astonishes me.  I've never heard of any such thing.  Nobody tells you these things.

% var=abc; print -- $var
abc

% abc=1; print -- $((var))
1

# abc was a string, now it's the name of an integer:
% let abc+=3; print -- $((var))
3

# var still wants to be scalar:
% var+=3; print -- $var
abc3

# So once var has been touched directly the link to abc is broken:
% abc+=2; print -- $((var))
0

% abc=2; print -- $((var))
0

... I suppose there's a good reason for it, but that leaves me dumbfounded.

% Sonnet_1='From_fairest_flowers_we_desire_increase'; print -- $Sonnet_1
From_fairest_flowers_we_desire_increase

% From_fairest_flowers_we_desire_increase=1        

% print -- $((Sonnet_1))
1

... ok ...

Anyway, the lesson is just not to assign a glob expansion to an integer.  Never, ever.  Sorry for the trouble gentlemen.







--------------kNtDSMCgvWO8ZyGpCsFgDo6s--