Date: Sat, 18 May 2002 23:11:24 -0400 From: "Benjamin P. Grubin" <bgrubin@pobox.com> To: "'Giorgos Keramidas'" <keramida@FreeBSD.ORG>, <current@FreeBSD.ORG> Subject: RE: mergemaster(8) broken -- uses Perl Message-ID: <000301c1fee2$dc221650$080aa8c0@VINZCLORTHO> In-Reply-To: <20020519022922.GA10039@hades.hell.gr>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?000301c1fee2$dc221650$080aa8c0>
