How can you keep yourself from running some of the commands in a directory in your ? For example, I use several different computers. I read and store my 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 makefor 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.
(Acan 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 allto each other:
The script uses the commandto include its (current) command name with the warning message: