Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

"Correct"-like behavior for `.' in the PATH



I've just been amusing myself by reading a thread about Linux for DOS users
and why not to have `.' in $PATH, and an idea for a feature struck me.

Why not have a shell option that lets zsh search the current directory for
executables, but that issues a prompt before executing them?

Here's how it'd work; call it `correct_dot' for this discussion:

When correct_dot is set, zsh first searches $PATH for the command.  If it
finds the command in the current directory, it remembers that and goes on
searching.  If it also finds it somewhere later, it prompts like this:

zsh: correct '/bin/ls' to './ls' [nyae]?

(Note that the thing NOT in `.' is the default answer.)

If it never finds it anywhere else, it prompts like this:

zsh: correct 'sl' to './sl' [nyae]?

It'd prompt only in the same instances where `correct' and `correctall' now
do so.  If it can't prompt, it would NOT execute commands from the current
directory, but rather behave as if `.' were not in the path at all.  (Or
just fail, I'm not sure which would be better.)

This could of course be generalized to an option that prompts whenever there
are two different path elements match the same command.

An additional option might be one to treat the path as if `.' were at the
end of it even when it isn't there, if and only if correct_dot was also set.
This would allow root to leave `.' out of his PATH, yet still discover that
a command was in the current directory.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



Messages sorted by: Reverse Date, Date, Thread, Author