Executable file named 'test' is in $PATH but won't run












12















I have a file in $HOME/bin (before you ask, yes, it is in my path) called test which I've confirmed can be executed fine when I run it with the full path to the file. However, I get a really weird issue when I don't run it this way. When I just run test in the terminal, it doesn't do anything and returns immediately. I know that this isn't an issue of finding the file for several reasons:




  1. There is no error message. Normally if the file can't be found or can't be executed a message will be printed out saying so.


  2. Running which test still returns the correct file path.


  3. Probably the weirdest of all - the script works fine when run through strace. I tried using strace to see if I could figure out what was going on but when I ran it with strace, it worked as expected with 0 issues.











share|improve this question




















  • 7





    Use type, not which. See Why not use “which”? What to use then?

    – wjandrea
    Feb 5 at 1:18













  • First tip at wiki-dev.bash-hackers.org/scripting/debuggingtips

    – Mark Wagner
    Feb 5 at 23:09
















12















I have a file in $HOME/bin (before you ask, yes, it is in my path) called test which I've confirmed can be executed fine when I run it with the full path to the file. However, I get a really weird issue when I don't run it this way. When I just run test in the terminal, it doesn't do anything and returns immediately. I know that this isn't an issue of finding the file for several reasons:




  1. There is no error message. Normally if the file can't be found or can't be executed a message will be printed out saying so.


  2. Running which test still returns the correct file path.


  3. Probably the weirdest of all - the script works fine when run through strace. I tried using strace to see if I could figure out what was going on but when I ran it with strace, it worked as expected with 0 issues.











share|improve this question




















  • 7





    Use type, not which. See Why not use “which”? What to use then?

    – wjandrea
    Feb 5 at 1:18













  • First tip at wiki-dev.bash-hackers.org/scripting/debuggingtips

    – Mark Wagner
    Feb 5 at 23:09














12












12








12


1






I have a file in $HOME/bin (before you ask, yes, it is in my path) called test which I've confirmed can be executed fine when I run it with the full path to the file. However, I get a really weird issue when I don't run it this way. When I just run test in the terminal, it doesn't do anything and returns immediately. I know that this isn't an issue of finding the file for several reasons:




  1. There is no error message. Normally if the file can't be found or can't be executed a message will be printed out saying so.


  2. Running which test still returns the correct file path.


  3. Probably the weirdest of all - the script works fine when run through strace. I tried using strace to see if I could figure out what was going on but when I ran it with strace, it worked as expected with 0 issues.











share|improve this question
















I have a file in $HOME/bin (before you ask, yes, it is in my path) called test which I've confirmed can be executed fine when I run it with the full path to the file. However, I get a really weird issue when I don't run it this way. When I just run test in the terminal, it doesn't do anything and returns immediately. I know that this isn't an issue of finding the file for several reasons:




  1. There is no error message. Normally if the file can't be found or can't be executed a message will be printed out saying so.


  2. Running which test still returns the correct file path.


  3. Probably the weirdest of all - the script works fine when run through strace. I tried using strace to see if I could figure out what was going on but when I ran it with strace, it worked as expected with 0 issues.








bash shell-script path executable strace






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 6 at 1:35









ivan_pozdeev

365211




365211










asked Feb 4 at 22:32









ContronThePandaContronThePanda

613




613








  • 7





    Use type, not which. See Why not use “which”? What to use then?

    – wjandrea
    Feb 5 at 1:18













  • First tip at wiki-dev.bash-hackers.org/scripting/debuggingtips

    – Mark Wagner
    Feb 5 at 23:09














  • 7





    Use type, not which. See Why not use “which”? What to use then?

    – wjandrea
    Feb 5 at 1:18













  • First tip at wiki-dev.bash-hackers.org/scripting/debuggingtips

    – Mark Wagner
    Feb 5 at 23:09








7




7





Use type, not which. See Why not use “which”? What to use then?

– wjandrea
Feb 5 at 1:18







Use type, not which. See Why not use “which”? What to use then?

– wjandrea
Feb 5 at 1:18















First tip at wiki-dev.bash-hackers.org/scripting/debuggingtips

– Mark Wagner
Feb 5 at 23:09





First tip at wiki-dev.bash-hackers.org/scripting/debuggingtips

– Mark Wagner
Feb 5 at 23:09










1 Answer
1






active

oldest

votes


















45














test is an unfortunate name to use, it's the standard utility for conditional tests. (It's actually the same command as the [ in if [ ... ], it just looks like a syntactical thing, but is really just a normal command.)



test is also builtin in e.g. Bash, so running just test never looks up your binary from the path.



bash$ help test | head
test: test [expr]
Evaluate conditional expression.

Exits with a status of 0 (true) or 1 (false) depending on
the evaluation of EXPR. Expressions may be unary or binary.
[...]


test with no arguments just returns 1 (false).



Running strace test doesn't involve the shell builtin, since strace doesn't implement any utilities itself. It just uses what it finds in your PATH. Note that you probably have the standard test in /bin/test or /usr/bin/test, so if that would be first in PATH, strace would run run that.



On my Bash, which is also an external command, so it doesn't have an idea about builtins either. On the other hand, the type command is builtin to the shell, and type test would show that test is a shell builtin.



See also: Why not use "which"? What to use then?






share|improve this answer





















  • 12





    Have an anecdote from 1985.

    – JdeBP
    Feb 4 at 23:09











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f498685%2fexecutable-file-named-test-is-in-path-but-wont-run%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









45














test is an unfortunate name to use, it's the standard utility for conditional tests. (It's actually the same command as the [ in if [ ... ], it just looks like a syntactical thing, but is really just a normal command.)



test is also builtin in e.g. Bash, so running just test never looks up your binary from the path.



bash$ help test | head
test: test [expr]
Evaluate conditional expression.

Exits with a status of 0 (true) or 1 (false) depending on
the evaluation of EXPR. Expressions may be unary or binary.
[...]


test with no arguments just returns 1 (false).



Running strace test doesn't involve the shell builtin, since strace doesn't implement any utilities itself. It just uses what it finds in your PATH. Note that you probably have the standard test in /bin/test or /usr/bin/test, so if that would be first in PATH, strace would run run that.



On my Bash, which is also an external command, so it doesn't have an idea about builtins either. On the other hand, the type command is builtin to the shell, and type test would show that test is a shell builtin.



See also: Why not use "which"? What to use then?






share|improve this answer





















  • 12





    Have an anecdote from 1985.

    – JdeBP
    Feb 4 at 23:09
















45














test is an unfortunate name to use, it's the standard utility for conditional tests. (It's actually the same command as the [ in if [ ... ], it just looks like a syntactical thing, but is really just a normal command.)



test is also builtin in e.g. Bash, so running just test never looks up your binary from the path.



bash$ help test | head
test: test [expr]
Evaluate conditional expression.

Exits with a status of 0 (true) or 1 (false) depending on
the evaluation of EXPR. Expressions may be unary or binary.
[...]


test with no arguments just returns 1 (false).



Running strace test doesn't involve the shell builtin, since strace doesn't implement any utilities itself. It just uses what it finds in your PATH. Note that you probably have the standard test in /bin/test or /usr/bin/test, so if that would be first in PATH, strace would run run that.



On my Bash, which is also an external command, so it doesn't have an idea about builtins either. On the other hand, the type command is builtin to the shell, and type test would show that test is a shell builtin.



See also: Why not use "which"? What to use then?






share|improve this answer





















  • 12





    Have an anecdote from 1985.

    – JdeBP
    Feb 4 at 23:09














45












45








45







test is an unfortunate name to use, it's the standard utility for conditional tests. (It's actually the same command as the [ in if [ ... ], it just looks like a syntactical thing, but is really just a normal command.)



test is also builtin in e.g. Bash, so running just test never looks up your binary from the path.



bash$ help test | head
test: test [expr]
Evaluate conditional expression.

Exits with a status of 0 (true) or 1 (false) depending on
the evaluation of EXPR. Expressions may be unary or binary.
[...]


test with no arguments just returns 1 (false).



Running strace test doesn't involve the shell builtin, since strace doesn't implement any utilities itself. It just uses what it finds in your PATH. Note that you probably have the standard test in /bin/test or /usr/bin/test, so if that would be first in PATH, strace would run run that.



On my Bash, which is also an external command, so it doesn't have an idea about builtins either. On the other hand, the type command is builtin to the shell, and type test would show that test is a shell builtin.



See also: Why not use "which"? What to use then?






share|improve this answer















test is an unfortunate name to use, it's the standard utility for conditional tests. (It's actually the same command as the [ in if [ ... ], it just looks like a syntactical thing, but is really just a normal command.)



test is also builtin in e.g. Bash, so running just test never looks up your binary from the path.



bash$ help test | head
test: test [expr]
Evaluate conditional expression.

Exits with a status of 0 (true) or 1 (false) depending on
the evaluation of EXPR. Expressions may be unary or binary.
[...]


test with no arguments just returns 1 (false).



Running strace test doesn't involve the shell builtin, since strace doesn't implement any utilities itself. It just uses what it finds in your PATH. Note that you probably have the standard test in /bin/test or /usr/bin/test, so if that would be first in PATH, strace would run run that.



On my Bash, which is also an external command, so it doesn't have an idea about builtins either. On the other hand, the type command is builtin to the shell, and type test would show that test is a shell builtin.



See also: Why not use "which"? What to use then?







share|improve this answer














share|improve this answer



share|improve this answer








edited Feb 5 at 9:58

























answered Feb 4 at 22:34









ilkkachuilkkachu

62.5k10103179




62.5k10103179








  • 12





    Have an anecdote from 1985.

    – JdeBP
    Feb 4 at 23:09














  • 12





    Have an anecdote from 1985.

    – JdeBP
    Feb 4 at 23:09








12




12





Have an anecdote from 1985.

– JdeBP
Feb 4 at 23:09





Have an anecdote from 1985.

– JdeBP
Feb 4 at 23:09


















draft saved

draft discarded




















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f498685%2fexecutable-file-named-test-is-in-path-but-wont-run%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Human spaceflight

Can not write log (Is /dev/pts mounted?) - openpty in Ubuntu-on-Windows?

張江高科駅