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 17599 invoked from network); 31 Mar 2023 20:17:09 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 31 Mar 2023 20:17:09 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1680293829; b=If4a+UrQ7NYae0iNF42RgpKAqRB/4R4vVn3V3eqg6dkI9mO2E5leSwlkJ31+L7Fry2rqKdljvR 8BP92AX7hKc6OlSQMsamr6yySt86js0eYbfzGfq+iojL3Yu99BfcuAn3cQFBOLHsG1MnMmDnrB S3pWZ3f3QCzkwQIK1r37GWq63HXcabcP/uSC2uihvwMt5dGFBSLcb+MwC/mAxazSAvC8qqWenI gJEvJR200eItUUdJjxbr3haTV4Ac8TEsG92rEOi1o2JQ6GiJhbSw8zef3oX2u/dLojW5LpBJNb Kwbhf5T208DWbgfcUQ+MySVOoSoz/gRfA6EX5KR58w9AXA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-yb1-f172.google.com) smtp.remote-ip=209.85.219.172; dkim=pass header.d=gmail.com header.s=20210112 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=1680293829; bh=9ka7NIgPqY5IUPkz4IBk8RbsCblP0zRjIVXWEmkOND4=; 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=UYCKHaEriXhUbCcoL5/R/qVFiMS4bNW9euupjKd/5DRQBXWrKjU1UCsTNAVBPgPjwmciJCx0wp oyAhgPdNtppB0KmxHQIU72By4t2PIJOtQb2h3kzew5ofRh1buQgU25ifH8yuCGGTCEBphN05yY IT0lse5X5il1H+iplEBC1yxyB0DJhAQ6YHRHHvuKqSxAsr0Bv3QAjqQJIfrTPDHgufJnB4t8+O 0/anQUSubEqLAbRzGsSMWA918fkVEjtpNrxGUdohHJCvD+CoKdQgirVIuk2ZB0+tUUszINhZHK KS4UJ1l+b7Q4w+qcup7aflAqBl+2g9EHdwD/F670AhXluA==; 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=gFe6WkFPo6YY1sQF6LDzz4+oIwgJc7gu6YeplyTDEVE=; b=aDoySOwFIoeonUy4IX1unmmqYF tX27JzdJu3ft7iA78HOM8RvPdZaClAMB51MAXDaDx+CFLq8Ezw+vXETEweC9LDIb+0E4p7h6bm1/m KNG7NKd9czKDJbzr7IUrd89PFC6bGin0YWqlGMf8nmOGWSmTGyoFudFI9XDl+uoq9K5SJvg9Tg5CU w34TruCqG7n7rWaNnqZjd2dbBAd0Dbt08Dumi8vQ9y/Sie7JUNI/X0jwQXV4QV/WzGpUN617wNNTs eg+0n23Jk2/kRJW3/giUY0KCMYSbSm+qJDayNxlH9m+5jCmUa0Asa4igr7EVio2hnJRnp+G36zPte LjLRa+rA==; Received: by zero.zsh.org with local id 1piLBM-000Hsa-MO; Fri, 31 Mar 2023 20:17:08 +0000 Authentication-Results: zsh.org; iprev=pass (mail-yb1-f172.google.com) smtp.remote-ip=209.85.219.172; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-yb1-f172.google.com ([209.85.219.172]:36594) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1piLAZ-000HBi-Po; Fri, 31 Mar 2023 20:16:21 +0000 Received: by mail-yb1-f172.google.com with SMTP id f188so10312160ybb.3; Fri, 31 Mar 2023 13:16:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680293777; 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=gFe6WkFPo6YY1sQF6LDzz4+oIwgJc7gu6YeplyTDEVE=; b=WUALCkJGg1QPd+moFyXtOff7W+K7A+8DwGRtFSK1/M6qur7580UZbmgxE3ri9E3kOz j+3+0igTho2G4eqYH5EvYC1ZCW33C1uL9li/4IMVWR7Tja/HYPqzDEjqXX8JQMie4JAJ k05U7nIu7wZbnHT04AUKT9rhsR5ZkqHi1wobPVOBTISkR64WdDHnPxMpos/TkEhfj9Jj 36XYnFGTC1kznfUAiY52WufuAbknRfhblmUZcuSjbBIoh8exyEONmuHUKPaF2wYId6Lg EzmcdsrhKyxnlondx1JJF4+3XdUl+BCejpDgiBPNcFfx1HTcIYEES+9aN0zhrq7gz7mO i7cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680293777; 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=gFe6WkFPo6YY1sQF6LDzz4+oIwgJc7gu6YeplyTDEVE=; b=pr5VSlQb8YXoeL3klsBeO7r3Bt6F2A0tzjqpFSEtzqVL3o3/PtfgA8xJC0iXUwfnUt kUI6bF9gY+34xKstWdINyev2noasMtuxZSXqITj9jxh5Sf2DT0b4uKVqqzPtNjP3VEZF s3mn0dSLmcvwT/yI7ogM3mPk6D14CkHe6r8tT3LpG5hGx5LWPlAKNfTJikVOAC0/DiI3 VOh0th/OXVBlbIE9chjo+/vkGP3Zf7PqaQnu5LUVNUJ1+ujynMHnA+xN+l+QFaPtqcyr WUnWW3j5iz7+2Qo0ZKxH7axWPqKkUrVEhwSmmhmQVUGWUjA7cq+T8nmOaL0JUak0rZnL 1Bvg== X-Gm-Message-State: AAQBX9fyPDSJQ01Mk4QTz35diT0DMxi4TreyIvAI8wxLNsRGDvSAwZvO zwEtbzDDp8CAS1pKOAj+MNW2axFgQlvShPbVHBQyCwofo20= X-Google-Smtp-Source: AKy350YaZa6ZFFfTIEwNQ3GN1nqIKYqvba1uUplm39Yclh8fYoO9RuV1P+zEZMr5OcI+GfAxAeJgusi6nGSgSIYypQM= X-Received: by 2002:a05:6902:1205:b0:b69:fab9:de60 with SMTP id s5-20020a056902120500b00b69fab9de60mr18532462ybu.0.1680293777538; Fri, 31 Mar 2023 13:16:17 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Felipe Contreras Date: Fri, 31 Mar 2023 14:16:06 -0600 Message-ID: Subject: Re: Discrepancy in IFS handling (zsh is POSIX compliant) To: =?UTF-8?Q?Lawrence_Vel=C3=A1zquez?= Cc: Zsh Users Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 29004 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 Thu, Mar 30, 2023 at 6:05=E2=80=AFAM Lawrence Vel=C3=A1zquez wrote: > > On Mar 30, 2023, at 7:13 AM, Felipe Contreras wrote: > > =EF=BB=BFHowever, this is what POSIX says: > > 3.b. Each occurrence in the input of an IFS character that is not > IFS white space, along with any adjacent IFS white space, shall > delimit a field, as described previously. > > We ignore all the white space stuff (since we are not using white > spaces), and thus: > > Each occurrence in the input of an IFS character shall delimit a field= . > > In zsh each occurrence of a comma does delimit a field (4 commas, 5 > fields), which to me is what POSIX says should happen. > > So in this particular case it seems zsh is complying with POSIX (even > in zsh mode), and all other shells are not. > > > Before the excerpt you quoted, XCU 2.6.5 says: =E2=80=9CThe shell shall t= reat each character of the IFS as a delimiter and use the delimiters as fie= ld terminators to split the results of parameter expansion, command substit= ution, and arithmetic expansion into fields.=E2=80=9D I was just about to mention that, and I thought I replied to you, but apparently not. So if IFS contains terminators, and not separators, this should generate 5 fields: IFS=3D';' str=3D'foo;bar;;roo;;' printf '"%s"\n' $str For: 'foo;' 'bar;' ';' 'roo;' ';' In which case bash is correct, and zsh is not. But, 'foo' doesn't contain any terminators, so it does not contain any field, and should be dropped. Unless 1) you consider the end of the string as a terminator, or 2) consider the terminator of the last field as optional. If you consider the end of the string as a terminator (1), then 'foo;' contains two fields, not one, in which case zsh is correct. This makes the terminators behave identically as separators. If you consider the terminator of the last field as optional, then bash (and other shells) are correct, but in that case what's the point of terminators if they aren't actually going to demarcate the *terminaton* of fields? I think everyone can agree POSIX is not clear about this. --=20 Felipe Contreras