Re: [wmii] snap: 20060313, proglist() spike

From: Paul TBBle Hampson <Paul.Hampson_AT_anu.edu.au>
Date: Tue, 14 Mar 2006 20:27:10 +1100

On Tue, Mar 14, 2006 at 09:56:33AM +0100, Bartosz Trudnowski wrote:
> 2006/3/14, Anselm R. Garbe <garbeam_AT_wmii.de>:

>> On Mon, Mar 13, 2006 at 12:27:01PM -0800, Suraj N. Kurapati wrote:
> >> Suraj N. Kurapati wrote:
> > >> echo "$PATH" | tr ':' '\n' | grep -v '^$' | sort -u | while read
> > >> dir; do find "$dir" -perm -u+x -type f -print | sed 's,^.*/,,'; done
> > > || sort -u

> >> Whoops, a small correction (\! -type d):

> >> echo "$PATH" | tr ':' '\n' | grep -v '^$' | sort -u | while read
> >> dir; do find "$dir" -perm -u+x \! -type d -print | sed 's,^.*/,,';
> >> done | sort -u

>> Can someone confirm if that works on BSD? Why are there two
>> 'sort -u' filters?

> First sort ensures, that there is no duplicates in PATH.

> The find args and the sort -u arg smell like a gnu...

> Solaris sort support this switch. Anyway - you can replace this with 'sort |
> uniq'.

> \! looks
>> very strange. What is wrong with -type f?

> Indeed. -type f should be sufficient.

'-type f' will miss things symlinked into the directory. This is
particularly bad on Debian, which uses symlinks to drive the
alternatives system, meaning that more binaries than you might expect
would suddenly not show up.

\(-type f -or -type l \) to my mind would do it... I don't imagine
anyone wants to execute a fifo, socket or device.

Alternative, -L makes find resolve symlinks it finds, so a symlink in
the bin to a file or directory will be correctly processed as either
matching or not matching -type f respectively. And -L is POSIX,
according to the GNU find manpage.

So how about:

find -L `echo "$PATH" | tr ':' ' ' ` -perm -u+x -type f -print | sed 's,^.*/,,' | sort -u

Only one find run, against all the paths at once... find is specified to
not visit the same directory twice anyway, so we save a uniq/sort call.
Hmm, only 5 invocations. That should help with the often-mentioned-here
overhead of ld-linux.so dynamic linking.

I guess for rc, replace `..` with `{..}

Is there a relevant shell that can't do inline output substitution?

-- 
-----------------------------------------------------------
Paul "TBBle" Hampson, BSc, MCSE
On-hiatus Asian Studies student, ANU
The Boss, Bubblesworth Pty Ltd (ABN: 51 095 284 361)
Paul.Hampson_AT_Anu.edu.au
"No survivors? Then where do the stories come from I wonder?"
-- Capt. Jack Sparrow, "Pirates of the Caribbean"
License: http://creativecommons.org/licenses/by/2.1/au/
-----------------------------------------------------------

Received on Tue Mar 14 2006 - 10:27:25 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 16:01:10 UTC