which-&which-version; and alternatives
The presence / absence of the which program in the main LFS book
is probably one of the most contentious issues we have on the mailing
lists. It has resulted in at least one flame war in the recent past.
To hopefully put an end to this once and for all, we here present the
various options for equipping your system with "which".
The first option is simply to use a bash alias:
alias which='type -p'
This command can be put in your
~/.bash_profile or ~/.bashrc
file in order to be set up each time you log in (see man bash for more
information on the bash login files). This will not always work
however, for example it will fail when a program needs to use "which"
but
doesn't spawn a shell.
The second option is to create a simple script:
cat > /usr/bin/which << "EOF"
#!/bin/bash
type -p "$@"
EOF
chmod 755 /usr/bin/which
chown root:root /usr/bin/which
This should generally work OK and is probably the easiest solution
for boxes which don't need a good user environment to work in.
The third option is to install the actual program
which.
&which-intro;
&which-inst;
&which-desc;