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.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE, 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 1352F21383 for ; Mon, 1 Apr 2024 15:52:58 +0200 (CEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1711979578; b=q66tWjcKMCJRxIj9bnrFBg4w0CCeBXA9AlsNG3/8Ikdf7sqwNEMoz47EldIb5NZEYoIWAcz2aR Tr4FxfKCH1rfjohmng2nvpXHYQmal/skRpOxuJAvbkg4GHVqdF1dlAtWoTnOIlKquom0qZereF 375WG9iO1kyyBY3GvB60eCkZLE+YA9RPGGCABnIJ6wfYZaKJPQZHyQARGnQnM3SKYy8YjnDshK ulF8vSMtBu0+j9tTVr4nXMvnfxxRgnXDw67upAdF+w6LTKYjXHGgaVHOciUBmgN93UOBU2vy+5 Mz6ucl20p4cOF+6Uu85+SwQA3lqay45mXK3Pv9N8DbYheA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mta02.eastlink.ca) smtp.remote-ip=24.224.136.13; 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=1711979578; bh=SAklEf1YLYuGD3kf4of1eTgZKRnW/zRDrZAODPOQCKk=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Subject:From:To:MIME-Version:Date:Message-ID:Content-Type: DKIM-Signature; b=nLRk4eEtEhB3jN7tVHmQjObBFlA2PJi4wDO4LscXU1WLFWD2xBnJGyIWZUQgEyNEhJPV8QpLaR 2UjeZ2EEXFt6PPmMc5cqSS4+buAz2bgI+0LagMK9LlH5sy0yy1bpggOnxUFkhA44RRHMuWlGZK ONEqWf1YezqVti0/cBt+Lu+/Vq/0zpIovZZ+M5zoipmZTmHj9p0BxFmMlH0+HWfMEzk9mSbeTQ ihZVtJa6zZIpHa69334AAMfvt773s5ru/VwhwuEDZg2kdwsPQeiikpzqPlrj3l6mY1mD5epG/G 6jDeqQWF8yeoeaMrYXqA1hZoURoqQcz0udAGnVnQ8YptEQ==; 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:Subject:From:To: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:In-Reply-To:References; bh=MYbE6A+JjhJVs1zYe5kYgmYHInKIibVNAYKjkghrTFA=; b=lXntzR733p6b1fAsK+7TmHv7Jb guBeYMcvNX4dREyL+6Ral6e1McZTNsFMcm2vURxjlayy0FSLPWhHNZSpYDzQxvmxnof+AHLjZWlnq 4DsCYSzePK71JBTZFaOPoFNkAV0QBPdDDFuifkVYK+FDQQw1/1le4hBa4GAggfwPRBWI7dIZ7HzFG tHaiJz6gKKz4kjwd0BiEnv+1MFXbNd10ndGsTjve1J37LqZlLKHtpzG1+yAh6Hbu6HW7m7ZfPPscp k8PmOfuqGtDOQvE1Ijab0Z3McLOpu6nkBsQm0ZmhgThfClN5LkC3A5pixbKN6cliiKgAC/9XmjXC5 8LybybCw==; Received: by zero.zsh.org with local id 1rrI5p-0002Y6-Ts; Mon, 01 Apr 2024 13:52:57 +0000 Authentication-Results: zsh.org; iprev=pass (mta02.eastlink.ca) smtp.remote-ip=24.224.136.13; dmarc=none header.from=eastlink.ca; arc=none Received: from mta02.eastlink.ca ([24.224.136.13]:51643) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rrI4x-0001qc-4i; Mon, 01 Apr 2024 13:52:03 +0000 Received: from csp01.eastlink.ca ([71.7.199.166]) by mta02.eastlink.ca ([24.224.136.13]) with ESMTPS id <0SB901OO0NU5HNE0@mta02.eastlink.ca> for zsh-users@zsh.org; Mon, 01 Apr 2024 10:52:01 -0300 (ADT) 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 rI4ur0B0HAimnrI4vruBQX (version=TLSv1_2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256); Mon, 01 Apr 2024 10:52:01 -0300 X-Authority-Analysis: v=2.4 cv=Q8Rx4J2a c=1 sm=1 tr=0 ts=660abc01 a=e7T7DzMKK1R988ZCg0wLyw==:117 a=e7T7DzMKK1R988ZCg0wLyw==:17 a=r77TgQKjGQsHNAKrUKIA:9 a=witeLzKDCWweH3QsxNIA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=IoPGjeLPYMDUEZycIgsA:9 a=7jpIRMeXGsbBELIE:21 a=_W_S_7VecoQA:10 X-Vade-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudeftddgjedtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecugfetuffvnffkpffmpdfqfgfvnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpegtkfffgggfvffhufesrgdtreertddvjeenucfhrhhomheptfgrhicutehnughrvgifshcuoehrrgihrghnughrvgifshesvggrshhtlhhinhhkrdgtrgeqnecuggftrfgrthhtvghrnhepfeefiedvtdekvdfgteekveduhfdtledtgeettddtkeeifffhuefhkeehgedtveetnecukfhppedvgedrvddtjedrudelrddufeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvgedrvddtjedrudelrddufedphhgvlhhopegludelvddrudeikedrtddruddungdpmhgrihhlfhhrohhmpehrrgihrghnughrvgifshesvggrshhtlhhinhhkrdgtrgdpnhgspghrtghpthhtohepvddprhgtphhtthhopeerredprhgtphhtthhopeiishhhqdhushgvrhhsseiishhhrdhorhhgpdhgvghtqdgkihhprfgrshhsfigupehtrhhuvg X-Vade-Score: -100 X-Vade-State: 0 X-EL-AUTH: rayandrews@eastlink.ca Content-type: multipart/alternative; boundary="------------R9ANTbHrQr0VrSdRyT4vYL8H" Message-id: Date: Mon, 1 Apr 2024 06:52:00 -0700 MIME-version: 1.0 User-Agent: Mozilla Thunderbird Content-language: en-US To: Zsh Users From: Ray Andrews Subject: unshift X-Seq: 29746 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. --------------R9ANTbHrQr0VrSdRyT4vYL8H Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Can we unshift the positional params?  I have a complex function that has shifts throughout and at one point there's a while loop: shift while [ "$1" ]; do     if [ a ]; then b; c  fi     if [ d ]; then e; f  fi     if [ g ]; then h; i  fi ... shift done ... works fine, but I'm thinking to restructure it: shift while [ "$1" ]; do     if [ a ]; then b; c; continue fi     if [ d ]; then e; f; continue fi     if [ g ]; then h; i; continue fi ... shift done ... because only one 'if' test will be relevant per loop and the remaining 'if' tests might even do some bad stuff.  The problem of course is that if I 'continue', the final 'shift' is missed.  I could do this: # shift while [ "$2" ]; do     shift     if [ a ]; then b; c; continue fi     if [ d ]; then e; f; continue fi     if [ g ]; then h; i; continue fi ... # shift done ... except that the leading (commented) 'shift' might happen in any number of places and changing them all would be troublesome.  It can be done of course, but I'm wondering if we have some way of  faking this: shift unshift while [ "$1" ]; do     shift     if [ a ]; then b; c; continue fi     if [ d ]; then e; f; continue fi     if [ g ]; then h; i; continue fi ... # shift done ... it looks pointless above, however note that the leading 'shift' might in fact have happened in any one of several different places all of which would need to be reworked and it's fragile, so the 'unshift' would take care of it in one place, at least temporarily.  I know we don't have an official unshift, but can it be faked?  Of course there's also this:     ...     if [ a ]; then b; c; shift; continue fi     ... ... but I'm wondering about a more succinct logic.  The quick and dirty 'unshift' idea would solve a temporary problem very nicely. --------------R9ANTbHrQr0VrSdRyT4vYL8H Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit Can we unshift the positional params?  I have a complex function that has shifts throughout and at one point there's a while loop:

shift
while [ "$1" ]; do
    if [ a ]; then b; c  fi
    if [ d ]; then e; f  fi
    if [ g ]; then h; i  fi
...
shift
done

... works fine, but I'm thinking to restructure it:

shift
while [ "$1" ]; do
    if [ a ]; then b; c; continue fi
    if [ d ]; then e; f; continue fi
    if [ g ]; then h; i; continue fi
...
shift
done

... because only one 'if' test will be relevant per loop and the remaining 'if' tests might even do some bad stuff.  The problem of course is that if I 'continue', the final 'shift' is missed.  I could do this:

# shift
while [ "$2" ]; do
    shift
    if [ a ]; then b; c; continue fi
    if [ d ]; then e; f; continue fi
    if [ g ]; then h; i; continue fi
...
# shift
done

... except that the leading (commented) 'shift' might happen in any number of places and changing them all would be troublesome.  It can be done of course, but I'm wondering if we have some way of  faking this:

shift
unshift
while [ "$1" ]; do
    shift
    if [ a ]; then b; c; continue fi
    if [ d ]; then e; f; continue fi
    if [ g ]; then h; i; continue fi
...
# shift
done

... it looks pointless above, however note that the leading 'shift' might in fact have happened in any one of several different places all of which would need to be reworked and it's fragile, so the 'unshift' would take care of it in one place, at least temporarily.  I know we don't have an official unshift, but can it be faked?  Of course there's also this:

    ...
    if [ a ]; then b; c; shift; continue fi
    ...

... but I'm wondering about a more succinct logic.  The quick and dirty 'unshift' idea would solve a temporary problem very nicely. 



--------------R9ANTbHrQr0VrSdRyT4vYL8H--