Wednesday, December 16, 2009

Don't use test as the name of your program in Unix/Linux

Remember, test itself is the internal shell command in Unix/Linux OS.

When you type in test, the name of the program you just wrote, you may realize your program doesn't work at all. You may spend lots of time in your program for debugging or struggle with your environment. Please don't waste your time; the puzzle is not in your program or your environment but the name, test.

The trick is that when test is entered from the command prompt, shell always run its test command instead. The only way you can start up your program is either to start your program with the full path "/PATH/test" or "bash test" if it is in the current directory.

The simple solution for this problem is NOT to use test as your program name.

No comments: