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

Re: tcsh -X behavior



Vincent Lefevre <vincent@xxxxxxxxxx> writes:

> Could we have the tcsh -X behavior in zsh conditional expressions?
> 
> The tcsh manual says:
> 
>          X   Executable in the path or shell builtin, e.g.  ` - X
>              ls'  and  ` - X  ls - F' are generally true, but `-X
>              /bin/ls' is not (+)

You want probably the hash builtin:

     hash [ -dfmr ] [ name[=value] ] ...

[snip...]

          value.  For each  name  with  no  corresponding  value,
          search  for name in the path, and add it to the command
          hash table, and  associating  it  with  the  discovered
          path, if it is found.

So in a shell-script:

if hash ls 2> /dev/null; then
        :
fi

-- 
Ervin
						"Intelligenti pauca."



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