On Mon, 14 May 2012, Ethan Grammatikidis wrote:

On Sun, 6 May 2012 22:49:17 -0700 Amit Uttamchandani wrote:

[...]

hash surf && surf http://localhost/

[...]

hash is a shell feature. bash and others cache the path - all the names - and sometimes when you've installed something since starting the shell, the shell won't find it. I think it only happens when you've removed it from one $PATH dir and installed it to another, in bash at least. Using hash in a just-started shell like the one running .xinintrc is pointless. :)

`hash [cmd-name]` is an idiom to determine whether a command exists in $PATH. I've been seeing it a lot recently as `hash [cmd-name] 2>&-` to suppress the errors when the cmd's not found. On my current system with only a few shells, the idiom works in bash, sh (symlink to bash), and zsh, but not in ksh (nor in csh ... but whocares):

bash$ hash dwm ; echo $?
0
bash$ hash nonexistent ; echo $?
bash: hash: nonexistent: not found
1

--
Best,
Ben

Reply via email to