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=0.2 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED autolearn=no autolearn_force=no version=3.4.4 Received: (qmail 16665 invoked from network); 12 Nov 2022 08:19:10 -0000 Received: from 9front.inri.net (168.235.81.73) by inbox.vuxu.org with ESMTPUTF8; 12 Nov 2022 08:19:10 -0000 Received: from wopr.sciops.net ([216.126.196.60]) by 9front; Sat Nov 12 03:15:40 -0500 2022 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sciops.net; s=20210706; t=1668240807; 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; bh=G26jj4y5/cPw9njtPGIEIfKj7dOE1XCWBYg+aUaUIMw=; b=HtK/eHoUi0p3QAzwcLpa7wt4idXWEw3OJ4jbHxeU34Kzzypj0BA15N3JZ/DQuh942M0+nm OimcfdfrHx71rcIwA2KtMgNcQPhZrhZj07fhT8ou4AMRKYUkfW9kCq+Un4SuhDYhZx7T60 5spDniGr2HvZetBCzuIA7YdnlZERTgw= Received: by wopr.sciops.net (OpenSMTPD) with ESMTPSA id 6ae5281f (TLSv1.2:ECDHE-RSA-CHACHA20-POLY1305:256:NO) for <9front@9front.org>; Sat, 12 Nov 2022 00:13:26 -0800 (PST) Message-ID: <9630E999FCA18103578EE0C514F78687@wopr.sciops.net> Date: Sat, 12 Nov 2022 09:15:31 +0100 From: qwx@sciops.net To: 9front@9front.org MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: private wrapper session-based framework Subject: [9front] this history(1) is scratched Reply-To: 9front@9front.org Precedence: bulk Hello, I'm having an issue with our new history(1) implementation: printing paths in the dump always fails for me. Example from the manpage: ; history /adm/users Feb 28 09:52:37 CET 2022 /adm/users 159 [adm] walk: path: /n/dump/2022/1111/adm/users: ' ' directory entry not found Nov 12 08:39:54 CET 2022walk: path: /n/dump/2022/1111/adm/users: ' ' directory entry not found walk: path: /n/dump/2022/0228/adm/users: ' ' directory entry not found Nov 12 08:39:54 CET 2022walk: path: /n/dump/2022/0228/adm/users: ' ' directory entry not found Same for any other file -- a space character is prepended to the paths, so walk(1) fails. The issue seems to be in the awk command at /rc/bin/history:39: [...] awk '"/n/'$dump/$since'" <= $2 {next} $1 != qid { qid=$1 gsub($1, "") print}' | [...] This does a substitution on $0, which retains the space between $1 and $2, even though $1 has been replaced by $2: ; echo 'a b' | awk '{gsub($1, ""); print}' b ; echo 'a b' | awk '{gsub($1, ""); print $1}' b If I understand the intent correctly, then the simplest fix is to add the space character to the regex: ; echo 'a b' | awk '{gsub($1" ", ""); print}' b It's also not necessary to call `gsub' instead of just `sub'. The thing is, this change is already a few months old, and I cannot imagine that the script has not worked for anyone in all of this time, including when it was first pushed, or that absolutely everyone has been using the old C version without noticing it. This behavior in awk is surprising to me, but is not 9front-specific. What the hell is going on? Can anyone else reproduce this? Any idea what I could be doing wrong? Including a fix below, if any is actually needed. Thanks, qwx diff 7a5a9b592af208aac719a6cfc0dacf44a5eebcef uncommitted --- a//rc/bin/history +++ b//rc/bin/history @@ -36,7 +36,7 @@ awk '"/n/'$dump/$since'" <= $2 {next} $1 != qid { qid=$1 - gsub($1, "") + sub($1" ", "") print}' | while(new=`$nl{read}){ prfile $new