8.8 A Directory for Commands You Shouldn't RunHow can you keep yourself from running some of the commands in a directory in your search path (6.4 , 6.5 ) ? For example, I use several different computers. I read and store my electronic mail (1.33 ) on just one computer - on that host, I want to use all the email commands. On the other computers, I want to be able to use mail-sending commands - but I don't want the mail-reading commands to work on my account there. You might work on a project with shared filesystems where some commands will only work on certain computers. How can you stop the commands from being run accidentally on computers where they shouldn't be? There's a beginner on the system who shouldn't be running dangerous commands. How can you stop him from using just those commands? You could make aliases (10.2 ) for those commands that just echo a message to the terminal. But having tens or hundreds of aliases like that can be a real headache. Here's how I solved my problem.
On all of my computers, the commands for the email system I use (called
MH) are stored in the directory /usr/local/mh
.
I make a directory named no_run.
(A per-host setup file (2.13 ) can help, too.) When I try to use a command that I shouldn't, the shell will find the shell script in the no_run directory before the real command in the mh directory. The shell script rings the bell, prints a message with its own name and the name of the computer to use, then quits: % To save disk space, the shell scripts in the no_run directory are all hard links (18.4 ) to each other: %
The script uses the command
The - |
|