From owner-freebsd-current Sat May 18 20:11:36 2002 Delivered-To: freebsd-current@freebsd.org Received: from mail.speakeasy.net (mail13.speakeasy.net [216.254.0.213]) by hub.freebsd.org (Postfix) with ESMTP id F18E037B407 for ; Sat, 18 May 2002 20:11:31 -0700 (PDT) Received: (qmail 30223 invoked from network); 19 May 2002 03:11:30 -0000 Received: from unknown (HELO VINZCLORTHO) ([66.92.70.186]) (envelope-sender ) by mail13.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 19 May 2002 03:11:30 -0000 From: "Benjamin P. Grubin" To: "'Giorgos Keramidas'" , Subject: RE: mergemaster(8) broken -- uses Perl Date: Sat, 18 May 2002 23:11:24 -0400 Message-ID: <000301c1fee2$dc221650$080aa8c0@VINZCLORTHO> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.3416 In-Reply-To: <20020519022922.GA10039@hades.hell.gr> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Importance: Normal Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Is [t]csh's `filetest` builtin viable here? Relurking, Ben > -----Original Message----- > From: owner-freebsd-current@FreeBSD.ORG > [mailto:owner-freebsd-current@FreeBSD.ORG] On Behalf Of > Giorgos Keramidas > Sent: Saturday, May 18, 2002 10:29 PM > To: current@FreeBSD.ORG > Subject: Re: mergemaster(8) broken -- uses Perl > > > On 2002-05-18 11:54, David O'Brien wrote: > > Anyone got a patch? > > Part of the problems I had when I tried to replace perl in > mergemaster.sh with something `native' was that the perl code uses > stat(2) to obtain the permission bits of a directory/file and I can't > think of a way to do this with tools in the base system without > resorting to ugly awk scripts that parse and translate ls(1) output. > > Any ideas? I am not really sure I like something like: > > % /bin/ls -ld /tmp | sed -e 's/[[:space:]].*$//' |\ > awk -v mode=0 '{ > if (match($0, "^.r........")) { mode += 00400; } > if (match($0, "^..w.......")) { mode += 00200; } > if (match($0, "^...S......")) { mode += 04000; } > if (match($0, "^...s......")) { mode += 04100; } > if (match($0, "^...x......")) { mode += 00100; } > if (match($0, "^....r.....")) { mode += 00040; } > if (match($0, "^.....w....")) { mode += 00020; } > if (match($0, "^......S...")) { mode += 02000; } > if (match($0, "^......s...")) { mode += 02010; } > if (match($0, "^......x...")) { mode += 00010; } > if (match($0, "^.......r..")) { mode += 00004; } > if (match($0, "^........w.")) { mode += 00002; } > if (match($0, "^.........T")) { mode += 01000; } > if (match($0, "^.........t")) { mode += 01001; } > if (match($0, "^.........x")) { mode += 00001; } > } > END { printf "0%o\n", mode; }' > > [ The above should print in stdout just 01777 as a number. ] > > It seems to work, but it's a bit ugly for my taste. Plus it will > break if the permission bits ever change representation (although this > is unlikely to happen any time real soon). > > Does anyone know of any other (possibly more elegant way) of reading > the numeric value of the permission bits for a file? > > -- > Giorgos Keramidas - http://www.FreeBSD.org > keramida@FreeBSD.org - The Power to Serve > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-current" in the body of the message > > > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message