From unknown Sat Jun 14 19:03:59 2025 X-Loop: help-debbugs@gnu.org Subject: bug#69939: test utility bug: "test -a -a -a" and "test -o -o -o" fail Resent-From: Vincent Lefevre Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Fri, 22 Mar 2024 12:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 69939 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: 69939@debbugs.gnu.org X-Debbugs-Original-To: bug-coreutils@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.17111094158018 (code B ref -1); Fri, 22 Mar 2024 12:11:02 +0000 Received: (at submit) by debbugs.gnu.org; 22 Mar 2024 12:10:15 +0000 Received: from localhost ([127.0.0.1]:47492 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rndiw-00025A-3Q for submit@debbugs.gnu.org; Fri, 22 Mar 2024 08:10:15 -0400 Received: from lists.gnu.org ([209.51.188.17]:52700) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rndL6-0000oW-Q4 for submit@debbugs.gnu.org; Fri, 22 Mar 2024 07:45:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rncwz-0000hF-73 for bug-coreutils@gnu.org; Fri, 22 Mar 2024 07:20:42 -0400 Received: from cventin.lip.ens-lyon.fr ([140.77.13.17]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rncwx-00021L-Ht for bug-coreutils@gnu.org; Fri, 22 Mar 2024 07:20:40 -0400 Received: from vlefevre by cventin.lip.ens-lyon.fr with local (Exim 4.97) (envelope-from ) id 1rncwj-00000001KRZ-2gQE; Fri, 22 Mar 2024 12:20:25 +0100 Date: Fri, 22 Mar 2024 12:20:25 +0100 From: Vincent Lefevre Message-ID: <20240322112025.GA316073@cventin.lip.ens-lyon.fr> Mail-Followup-To: Vincent Lefevre , bug-coreutils@gnu.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Mailer-Info: https://www.vinc17.net/mutt/ User-Agent: Mutt/2.2.12+69 (354c5b11) vl-149028 (2023-12-10) Received-SPF: pass client-ip=140.77.13.17; envelope-from=vincent@vinc17.net; helo=cventin.lip.ens-lyon.fr X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) With GNU Coreutils 9.4, both "test -a -a -a" and "test -o -o -o" fail: $ export POSIXLY_CORRECT=1 $ /usr/bin/test -a -a -a ; echo $? /usr/bin/test: ‘-a’: unary operator expected 2 $ /usr/bin/test -o -o -o ; echo $? /usr/bin/test: ‘-o’: unary operator expected 2 According to POSIX, they should return 0. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html says for 3 arguments: If $2 is a binary primary, perform the binary test of $1 and $3. Here, $2 is -a and -o respectively, which are binary primaries. And both $1 and $3 are non-null strings. -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon) From unknown Sat Jun 14 19:03:59 2025 X-Loop: help-debbugs@gnu.org Subject: bug#69939: test utility bug: "test -a -a -a" and "test -o -o -o" fail Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Fri, 22 Mar 2024 17:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69939 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Vincent Lefevre , 69939@debbugs.gnu.org Received: via spool by 69939-submit@debbugs.gnu.org id=B69939.17111274176121 (code B ref 69939); Fri, 22 Mar 2024 17:11:02 +0000 Received: (at 69939) by debbugs.gnu.org; 22 Mar 2024 17:10:17 +0000 Received: from localhost ([127.0.0.1]:36211 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rniPI-0001ae-Dl for submit@debbugs.gnu.org; Fri, 22 Mar 2024 13:10:17 -0400 Received: from mail-wm1-f41.google.com ([209.85.128.41]:50245) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rni2u-0000Ug-1a for 69939@debbugs.gnu.org; Fri, 22 Mar 2024 12:47:09 -0400 Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-414787c73c7so8950525e9.0 for <69939@debbugs.gnu.org>; Fri, 22 Mar 2024 09:46:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711125921; x=1711730721; darn=debbugs.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=/QFAxv21EM8auCpYUDIb7SiAStaQI5cd0ufEXd7WhUA=; b=GSXR2JZu2VdI81KWPUMUxABSbfWPsomRO9yVsQpGwui+a/jAvEiWiGxV413jJSgvko FnuSfIEvfMsQlRBHYTJ+QPMxGw7K63aSrXqjtPBwjB9cFeG6NS82PdT/yq6bYgN7nnLY qqZXOC4COQ3rw4Ab1+c2Y2pD95H0qjlHjLn9zoYC7XaTZSMEz2Xm2nrZbTP1JvzlaKYD vwfBixjE+52uYxGiMyD85LBsbRG8A9xL00KLkQn29mOTUsBbAgYNEMt0pC02bwEqRi2I Gb9D9VDyC0pnGOBqeAiyCJTVib4+VI0YYf1/8Ncfkhoi8axQeOKXjRrgOITLWXNHuF46 5P/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711125921; x=1711730721; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/QFAxv21EM8auCpYUDIb7SiAStaQI5cd0ufEXd7WhUA=; b=aNagyNrvpYbxm6BvsM7OuIM91fjpzR1qBy/83ag4XeoOLs1+DEFFkfkNETt/H95C2H nMQUgsu+kK6XdyO2zDgV8nFv6zw6MQEso4y+qctAd74V1mn+wX5ngZl1oDJS77JKaOzc mqtugck5XB0+mN8kVkJQ/59azkc1cgMovwbaXLideUvr8AnLtFX6yVwV+zjpr727APbx 3pVZ48MpUbYTKjjaa2n5I0x8WG8Lcu/FQy1zNnSrOWRidGnhJ0w67kf5lj8KPCK/ZZZY 5t4TOJv9W7uk0RuTGd5uYWoC/1yk3RDCopYtQ73lOD82cFZQirsNVuyMrCAsdPAgivdq ROgw== X-Forwarded-Encrypted: i=1; AJvYcCV6Fy2i+lxvbHO+mn59gct9l+y+6uvTsiPNe46s6VJY+oixflDGjTD5SR5Vu+4l6L4eHwvQpcxjblMRM9Rdgk2Xh6J7TCI= X-Gm-Message-State: AOJu0YwCPEDilaMkV/oX/OSCgjOAQ9KrEbWyn5OR6ZbPmJODCZVdnqf/ 0VYWblvdcdTx/5Qojfv9Yalwq3kKGu/XsDCWYbD4ty/xfHjd/qJNvoRFTUh8 X-Google-Smtp-Source: AGHT+IGFMNgR2GSq3nKkxbxWSr4HXlSc7UoRh6CDMLJ0l11wIy/CT4hbTwl2uKwQmKIZPDvc/mjMcQ== X-Received: by 2002:a05:600c:1ca9:b0:414:7e73:1f5b with SMTP id k41-20020a05600c1ca900b004147e731f5bmr842033wms.4.1711125921006; Fri, 22 Mar 2024 09:45:21 -0700 (PDT) Received: from [192.168.1.39] (86-44-211-146-dynamic.agg2.lod.rsl-rtd.eircom.net. [86.44.211.146]) by smtp.googlemail.com with ESMTPSA id h9-20020a05600016c900b00341b7d5054bsm1603911wrf.72.2024.03.22.09.45.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 22 Mar 2024 09:45:20 -0700 (PDT) Message-ID: <9f7199bd-82fa-98f2-755f-8c6c27b78b31@draigBrady.com> Date: Fri, 22 Mar 2024 16:45:19 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US References: <20240322112025.GA316073@cventin.lip.ens-lyon.fr> From: =?UTF-8?Q?P=C3=A1draig?= Brady In-Reply-To: <20240322112025.GA316073@cventin.lip.ens-lyon.fr> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: 0.2 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) On 22/03/2024 11:20, Vincent Lefevre wrote: > With GNU Coreutils 9.4, both "test -a -a -a" and "test -o -o -o" fail: > > $ export POSIXLY_CORRECT=1 > $ /usr/bin/test -a -a -a ; echo $? > /usr/bin/test: ‘-a’: unary operator expected > 2 > $ /usr/bin/test -o -o -o ; echo $? > /usr/bin/test: ‘-o’: unary operator expected > 2 > > According to POSIX, they should return 0. > > https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html > says for 3 arguments: > > If $2 is a binary primary, perform the binary test of $1 and $3. > > Here, $2 is -a and -o respectively, which are binary primaries. > And both $1 and $3 are non-null strings. Agreed. Any leading '-' triggers this: $ env test -. -a -. test: ‘-.’: unary operator expected Note we already advise (as does POSIX) to avoid '-a' and '-o': https://debbugs.gnu.org/22909 BTW POSIX advises to use parenthesis to avoid some parsing ambiguities, and it helps in this case too: $ env test \( -a \) -a \( -a \); echo $? 0 Though I see bash 5.2.26 has issue with it :/ $ test \( -a \) -a \( -a \) bash: test: `)' expected bash doesn't like the -a in particular, and is ok with other strings: $ test \( -. \) -a \( -. \); echo $? 0 cheers, Pádraig From unknown Sat Jun 14 19:03:59 2025 X-Loop: help-debbugs@gnu.org Subject: bug#69939: test utility bug: "test -a -a -a" and "test -o -o -o" fail Resent-From: Andreas Schwab Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Fri, 22 Mar 2024 17:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69939 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: =?UTF-8?Q?P=C3=A1draig?= Brady Cc: Vincent Lefevre , 69939@debbugs.gnu.org Received: via spool by 69939-submit@debbugs.gnu.org id=B69939.171112921711331 (code B ref 69939); Fri, 22 Mar 2024 17:41:02 +0000 Received: (at 69939) by debbugs.gnu.org; 22 Mar 2024 17:40:17 +0000 Received: from localhost ([127.0.0.1]:38079 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rnisK-0002wg-8G for submit@debbugs.gnu.org; Fri, 22 Mar 2024 13:40:16 -0400 Received: from mail-out.m-online.net ([212.18.0.9]:46166) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rnili-0002gN-Tz for 69939@debbugs.gnu.org; Fri, 22 Mar 2024 13:33:27 -0400 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4V1Tj726fHz1qsPc; Fri, 22 Mar 2024 18:24:42 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.68]) by mail.m-online.net (Postfix) with ESMTP id 4V1Tj66lsZz1qqlW; Fri, 22 Mar 2024 18:24:42 +0100 (CET) X-Virus-Scanned: amavis at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.68]) (amavis, port 10024) with ESMTP id JeyV5E54oy0r; Fri, 22 Mar 2024 18:24:42 +0100 (CET) X-Auth-Info: nWDxkmpsI4nxoFrhCyYOBHLgieTDAEB8ORyIWvc7ou0zjYElmSbNc3n+ueSBNJma Received: from igel.home (aftr-62-216-202-134.dynamic.mnet-online.de [62.216.202.134]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Fri, 22 Mar 2024 18:24:42 +0100 (CET) Received: by igel.home (Postfix, from userid 1000) id F0A692C1A75; Fri, 22 Mar 2024 18:24:41 +0100 (CET) From: Andreas Schwab In-Reply-To: <9f7199bd-82fa-98f2-755f-8c6c27b78b31@draigBrady.com> ("=?UTF-8?Q?P=C3=A1draig?= Brady"'s message of "Fri, 22 Mar 2024 16:45:19 +0000") References: <20240322112025.GA316073@cventin.lip.ens-lyon.fr> <9f7199bd-82fa-98f2-755f-8c6c27b78b31@draigBrady.com> X-Yow: Hey, I LIKE that POINT!! Date: Fri, 22 Mar 2024 18:24:41 +0100 Message-ID: <878r2ayyau.fsf@igel.home> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.5 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.5 (-) On Mär 22 2024, Pádraig Brady wrote: > Though I see bash 5.2.26 has issue with it :/ > > $ test \( -a \) -a \( -a \) > bash: test: `)' expected > > bash doesn't like the -a in particular, and is ok with other strings: That's because in bash -a is ambiguous: -a FILE True if file exists. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."