0

I have two identical files in my ~/bin folder, test and test2. Both just print a string. One works; the other, which I just put in there today, doesn't. In fact nothing happens at all, which is odd. Do I need to refresh the path or something? How do I get it to recognize this new program in ~/bin?

(I'm running it just by typing "test" from anywhere, although I did try typing it from within the bin directory too.)


Solved. This is apparently a problem with having a program named "test". I copied it to "test3" and it works. In fact anything but "test" works.

closed as off-topic by jasonwryan, roaima, Jeff Schaller, jimmij, Scott Apr 12 '16 at 0:39

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – jasonwryan, roaima, Jeff Schaller, jimmij, Scott
If this question can be reworded to fit the rules in the help center, please edit the question.

  • The output is "test". The output of test2, though, is "/home/me/bin/test2". – felwithe Apr 11 '16 at 23:05
  • test is a built-in command. Unfortunate perhaps but that's how it is. – roaima Apr 11 '16 at 23:26
3

I assume test doesn't work. The reason is, test is a shell builtin. Try running

$ type test2
> test2 is /home/user/bin/test2

$ type test
> test is a shell builtin

The test shell builtin is used to test conditions, e.g.:

if test "x" = "x"; then
    echo yeah
fi

The reason why this isn't used often anymore, is that it can also be written by using [:

if [ "x" = "x" ]; then
    echo yeah
fi
  • I just figured this out myself. – felwithe Apr 11 '16 at 23:06
  • @felwithe if you really want to have a program named test, call it with the full or relative path -- ~/bin/test or /home/user/bin/test or (cd ~/bin; ./test) – Jeff Schaller Apr 11 '16 at 23:47
  • @JeffSchaller I don't, "test" is just my default and I was trying some things today. Calling it directly did work, but I was testing the way the bin directory acted specifically. – felwithe Apr 12 '16 at 2:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.