From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id F077D1F4B4 for ; Mon, 12 Apr 2021 18:48:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236725AbhDLStP convert rfc822-to-8bit (ORCPT ); Mon, 12 Apr 2021 14:49:15 -0400 Received: from mail-ej1-f49.google.com ([209.85.218.49]:36827 "EHLO mail-ej1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236804AbhDLStO (ORCPT ); Mon, 12 Apr 2021 14:49:14 -0400 Received: by mail-ej1-f49.google.com with SMTP id r9so21976028ejj.3 for ; Mon, 12 Apr 2021 11:48:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=YJEZhUtY2D0XDeF2ZIjiMbXMaUkcJ9/cN7rceyZdfMQ=; b=MPA+WEx0yd7874wH29UtQdNWsxljMLVoK0XmIfSco1btKriz0N8X+pWAuL9/zPfR7c 8ZhDMD187o6FfYtViKC1QNjBsD/YJ1RRCdTV/i6xuOWMiiFQArg/Z41rve71+m16XbA+ /hbiE7XVsP52/cZ9eDsUd2NppB2IWmSR0AxpyEmnvDPTaCd6b7zQS1qx5fGQF4goTtVE rBwv/MS5I+uYTZjRz8b325+onjG9WVtEWPoiFizIY6+3FNoLBvYCs85Zi01Byv0zPpoT NVLX4sX+EPrbOZsuazwterIF3OigG86HGA0jVh3b4w9uM4unTYnJD8p0RcTIKU2qt76t 5TrQ== X-Gm-Message-State: AOAM531LeqUnDFTAE8eWqvk9xUwuU/dwC/bJ2C4wZmCKLOemIvaQ7VZZ yaR+4Vfg6Ox0lPUGtlyz3JFWr55oOCGHneWJj6Q= X-Google-Smtp-Source: ABdhPJwLtC/vH/j1OIBVjGs4mMd22ctBVkb2H7WOWUPkS5x8RYvhjvjNVn1MDBkn5q4uup2T7BEX/zlUMgrw+HUFJqk= X-Received: by 2002:a17:906:85cb:: with SMTP id i11mr8178186ejy.311.1618253333903; Mon, 12 Apr 2021 11:48:53 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Eric Sunshine Date: Mon, 12 Apr 2021 14:48:43 -0400 Message-ID: Subject: Re: [PATCH 01/16] check-non-portable-shell: complain about "test" a/-o instead of &&/|| To: Junio C Hamano Cc: =?UTF-8?B?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= , Git List , Jeff King , Matthieu Moy , Johannes Schindelin Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Mon, Apr 12, 2021 at 2:38 PM Junio C Hamano wrote: > Eric Sunshine writes: > >> + /\btest\s+-[a-z]\s+.*?\s+-a\s+/ and err '"test A && test B" preferred to "test A -a B"'; > >> + /\btest\s+-[a-z]\s+.*?\s+-o\s+/ and err '"test A || test B" preferred to "test A -o B"'; > > > > These will only match the simplistic forms of `test -X blah` (where > > "-X" is some single letter option), but will miss expressions such as > > `test "$foo" = bar`. Crafting a regex to match more generally would be > > non-trivial, so this simpler match is a reasonable start. Okay. > > Would it be a trivial improvement to do > > 'test', followed by anything other than '&' or '|', and then > followed by '-a' or '-o' > > instead? That seems plausible and trivial enough. In fact, I think it eliminates a source of false-positives that Ævar's pattern can report, such as: test whatever && ls -a foo and test whatever && foo -o outfile among others.