[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cd path searching



> Anyway, I noticed that in es-0.90 alpha, the cdpath searching code
> was removed from init.es.

It was removed based on comments made on the list.  I initially
opposed removing it, but was convinced that was the right thing.

> This is one thing that I use day in, day out, and rely on extremely
> heavily.

You're not alone.

> It is, in fact, what has kept me from switching to the new version
> from 0.84.

Sorry to hear that.

> Much as I hate to have to admit this, I really am too busy (or lazy
> :-) to bother ripping the code out of the old version and putting it
> in my .esrc.

Here it is, pre-ripped.  No warranty.

	let (cd = $fn-cd) fn cd dir {
		if {~ $#dir 1} {
			if {!%is-absolute $dir} {
				let (old = $dir) {
					dir = <={%cdpathsearch $dir}
					if {!~ $dir $old} {
						echo >[1=2] $dir
					}
				}
			}
			$cd $dir
		} {
			$cd $dir
		}
	}
	
	fn %cdpathsearch name { access -n $name -1e -d  $cdpath }
	fn %is-absolute path { ~ $path /* ./* ../* }

	set-cdpath = @{local (set-CDPATH=) CDPATH=<={%flatten : $*}; result $*}
	set-CDPATH = @{local (set-cdpath=) cdpath=<={%fsplit  : $*}; result $*}
	noexport = $noexport cdpath
	cdpath = ''

> So, can we please put it back into init.es?  Maybe inside an if for
> a variable or something so that people can turn it off if they don't
> want it, or even turn it on if they do.

Certainly not under a switch.

Es's customizability is what distinguishes it from other shells.  It
would seem a shame to me to have this features handles specially.