From owner-freebsd-current Sun May 19 4:26:15 2002 Delivered-To: freebsd-current@freebsd.org Received: from mailsrv.otenet.gr (mailsrv.otenet.gr [195.170.0.5]) by hub.freebsd.org (Postfix) with ESMTP id 4788637B407 for ; Sun, 19 May 2002 04:26:08 -0700 (PDT) Received: from hades.hell.gr (patr364-a07.otenet.gr [195.167.109.39]) by mailsrv.otenet.gr (8.12.3/8.12.3) with ESMTP id g4JBQ1QJ020479; Sun, 19 May 2002 14:26:02 +0300 (EEST) Received: from hades.hell.gr (hades [127.0.0.1]) by hades.hell.gr (8.12.3/8.12.3) with ESMTP id g4JBQ0Iu033350; Sun, 19 May 2002 14:26:00 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from charon@localhost) by hades.hell.gr (8.12.3/8.12.3/Submit) id g4JBQ0lA033349; Sun, 19 May 2002 14:26:00 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Sun, 19 May 2002 14:25:59 +0300 From: Giorgos Keramidas To: Alfred Perlstein Cc: Bakul Shah , Dima Dorfman , Paul Herman , current@FreeBSD.org Subject: Re: mergemaster(8) broken -- uses Perl Message-ID: <20020519112559.GA33290@hades.hell.gr> References: <200205190707.DAA27939@marlborough.cnchost.com> <200205190730.DAA10754@marlborough.cnchost.com> <20020519091354.GR20683@elvis.mu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020519091354.GR20683@elvis.mu.org> User-Agent: Mutt/1.3.99i 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 On 2002-05-19 02:13, Alfred Perlstein wrote: > * Bakul Shah [020519 00:30] wrote: > > > $ stat -a stat > > > > Oops! A few lines got eaten! > > > > $ stat -a stat > > May 19 00:24:42 2002|48|May 19 00:24:42 2002|291846|-|bakul|0|262301|1|May 19 00:24:42 2002|rwxr-xr-x|1095744|23996|-|bakul|stat > > $ stat -a -n stat > > 1021793082|48|1021793082|291846|0|1001|0|262301|1|1021793082|755|1095744|23996|100000|1001|stat > > Bow to me. > > echo 'ibase=2\nobase=8\n' \ > `ls -ld ${FILE} | cut -f 1 -d " " | \ > sed -e 's/[rwx]/1/g' -e 's/[^rwx1]/0/g'` | \ > bc Great idea to use bc(1) ;-) It doesn't really parse sticky, suid or sgid bits, but it's smaller than the awk version. The following did the trick nicely (but is too ``complicated'', and I'd still like having a tool that allows userland to call stat/fstat(2): hades+charon:/tmp$ cat foo.sh #!/bin/sh echo 'ibase=2;obase=8;' \ ` ls -ld "$1" | \ cut -c2-10 | \ sed -e '/^..[sS]/ s/^.*$/&+100000000000/' \ -e '/^.....[sS]/ s/^.*$/&+10000000000/' \ -e '/^........[tT]/ s/^.*$/&+1000000000/' | \ sed -e 's/[st]/x/g' -e 's/ST/-/g' | \ sed -e 's/[rwx]/1/g' | \ sed -e 's/[^1+]/0/g' ` | bc % sh foo.sh /tmp hades+charon:/tmp$ sh foo.sh /tmp 1777 -- 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