Re: (OT) path_helper [was Re: Xterm not reading dotfiles]
Re: (OT) path_helper [was Re: Xterm not reading dotfiles]
- Subject: Re: (OT) path_helper [was Re: Xterm not reading dotfiles]
- From: "Mark J. Reed" <email@hidden>
- Date: Mon, 19 Nov 2007 07:17:26 -0500
The case sxpr *:$p:* is not sufficient to check for $p already in the
path because it won't match if $p is the first or last element in the
path.
Read -uN is not compatible with vanilla sh, but then I'm not sure
there's any way to avoid munging exterior whitespace in vanilla sh
either. Read -u does at least work in ksh and POSIX sh (and so
presumably zsh as well).
Read <&N might work, but I suspect it would trigger a subshell.
On 11/19/07, Vernon Williams <email@hidden> wrote:
> Monday, November 19, 2007, 3:16am
>
> For whatever it is worth, attached below is a little C program I just
> hacked out to list its command arguments to standard output,
> in order, but with any duplicates (except for the first) removed.
> It could readily be converted into a filter as well. It is a fast,
> general
> purpose program for removing duplicates, using two qsorts,
> which might be useful in the current problem, at least for the
> algorithm. I have not tested it extensively, but it seems to work
> for the cases I have tried. If anybody tries it and finds any problems,
> I would be glad to hear about it.
>
> Vernon Williams
>
> On Nov 18, 2007, at 10:33 PM, Andrew J. Hesford wrote:
>
> >
> > On Nov 18, 2007, at 8:24 PM, Mark J. Reed wrote:
> >
> >> IMESHO, this particular program might be best written in a different
> >> language. C, for instance. Or Perl/Python/Ruby/Tcl - they all ship
> >> standard with OSX, right? Any of them would probably do this more
> >> efficiently than bash; it's not the sort of thing the shell is
> >> optimized for.
> >
> > I re-implemented path_helper in Perl, and it's attached. I'd
> > appreciate if people would give it a try. I'm no Perl hacker, so maybe
> > it's horrendously stupid, but it seems okay to me. It seems to
> > duplicate the exact functionality of the original path_helper. Any
> > existing PATH or MANPATH contents are preserved, in order. Next, the
> > /etc/{man,}paths files are read for defaults, and finally, the files
> > in /etc/{man,}paths.d are processed.
> >
> > For efficient checking for duplicates, I use hashes. Perl is supposed
> > to be good at this, so it should be reasonably efficient. Time tests
> > reveal no noticeable difference in user time (0.01 sec) or system time
> > (0.00 sec), but the wall-clock time of my script is consistently half
> > of the system path_helper run time (0.011 versus 0.022 sec). This even
> > includes the simplified glob posted earlier by Nate.
> >
> > Oh, and it works properly with LaTeXiT, too. (Does anybody care about
> > this but me?)
> >
> > <path_helper.pl>
> >
> > --
> > Andrew J. Hesford <email@hidden>
> > Department of Electrical and Computer Engineering
> > University of Illinois at Urbana-Champaign
> >
>
--
Mark J. Reed <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
X11-users mailing list (email@hidden)
This email sent to email@hidden