From nobody Fri Aug 09 18:33:32 2024 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WgXbx05FYz5Scs5 for ; Fri, 09 Aug 2024 18:33:33 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WgXbw3WSYz4K9y for ; Fri, 9 Aug 2024 18:33:32 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1723228412; a=rsa-sha256; cv=none; b=gJDi7DdHXnzquVijejqAgEeNxYFzZHimUV6Ov0JE+VGfmZs7Ff62vynFnmM7DFnT1ijy6F dmrr8WIfCtY8xE8CyxiRQ2cyvAEA6TNqLmQYuh8SC/gj70l+KMC7YEOYyDXPpgy8jw/68A jZLLk5EL4X2d2HbcyxXltCivrIr+UQWZeF+iVFC06JvAUFDVXxOPwxQ4VnMVjnPSTDrhkb lEmOTt6pTQ3qGXwJqjx0kRUFkqdS4ghHNodf0FNbLkZwEkJHhvlNVB6WKjq8/SmXgnjPPA /xQFM1f6isXTIhwbHlPvnqSc6GkwS1wBgUtZmFhDcr0/8/aWJITeBv3d2xRRnQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1723228412; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mw3wcQjArtS5nrIEj9dx5uBiPLRg89ND9R9O1HI0X0g=; b=cDiRA+g2802bVIwhuN7Z1z3QqIQu55xEV/BIvMZ6wD5gZ0AZGKMRlQxQ8G7WziCCGegM4C kQF1CP5/qvq42jOpdNk5iyQT5buj26IkqZWat6s8QY+UMJWAlsXOC/Jh4Z2d7VoB1icCTk fO2VwUFyiXSvI7/Fn52BRU+hND330wDdVlXbRvqq+ApPnMBuHttKNvHbIKG9k6xhmExBic bnLETx3FxQXb78rnYg4QjX4/RTbRwLFeSSriWOv+fzcwW4iH4WrresC/PZGIvDxmaKRJqS p1gPP6lCj4AFxelCVvMgF4QI+D0a50d7R4Ihaxp6TUuKR+n0CHdbDEeUtdjt3w== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4WgXbw2R32zRqf for ; Fri, 9 Aug 2024 18:33:32 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 479IXW1c071230 for ; Fri, 9 Aug 2024 18:33:32 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 479IXWUG071223 for bugs@FreeBSD.org; Fri, 9 Aug 2024 18:33:32 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 280676] grep default recursive behavior differs from manpage Date: Fri, 09 Aug 2024 18:33:32 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: 14.1-STABLE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: jhb@FreeBSD.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@FreeBSD.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D280676 --- Comment #3 from John Baldwin --- Looks like macOS uses BSD grep, and it fixed the code to match the manpage.= =20 BSD grep treats '-r' and '-R' as identical, whereas GNU grep uses '-r' to m= ean the equivalent of '-rO' in BSD grep and '-R' to mean the equivalent of '-rS= '. However, it seems like the grep in FreeBSD is a bit more broken. To test, I created a hierarchy like so: ``` > ls -l total 2 drwxr-xr-x 2 john john 3 Aug 9 14:20 bar drwxr-xr-x 2 john john 3 Aug 9 14:20 baz lrwxr-xr-x 1 john john 11 Aug 9 14:20 foo -> bar/foo.txt > ls -l bar/ total 1 -rw-r--r-- 1 john john 5 Aug 9 14:19 foo.txt > ls -l baz total 1 lrwxr-xr-x 1 john john 14 Aug 9 14:20 bar.txt -> ../bar/foo.txt > cat bar/foo.txt=20 blah ``` I then tested grep -r on macOS with various options which gave the followin= g: ``` > grep -r blah foo bar baz bar/foo.txt:blah > grep -rS blah foo bar baz foo:blah bar/foo.txt:blah baz/bar.txt:blah > grep -rO blah foo bar baz foo:blah bar/foo.txt:blah ``` On FreeBSD it seems that the options don't really work at all: ``` > grep -rS blah foo bar baz foo:blah bar/foo.txt:blah baz/bar.txt:blah > grep -rO blah foo bar baz foo:blah bar/foo.txt:blah baz/bar.txt:blah > grep -rp blah foo bar baz foo:blah bar/foo.txt:blah baz/bar.txt:blah ``` That is to say, it acts like -S is always enabled. One issue is that when = -O is specified, we only include FTS_COMFOLLOW in the flags passed to fts_open= () in grep_tree(), when it should be FTS_COMFOLLOW | FTS_PHYSICAL in that case (the fts manpage says that one of FTS_LOGICAL or FTS_PHYSICAL must be specified). But it is also true that in the code the default setting of 'link_behave' is indeed -S. --=20 You are receiving this mail because: You are the assignee for the bug.=