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









New contributor




ContronThePanda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 7





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

    – wjandrea
    yesterday













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

    – Mark Wagner
    6 hours ago
















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









New contributor




ContronThePanda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 7





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

    – wjandrea
    yesterday













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

    – Mark Wagner
    6 hours ago














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









New contributor




ContronThePanda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












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









New contributor




ContronThePanda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




ContronThePanda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 4 hours ago









ivan_pozdeev

36619




36619






New contributor




ContronThePanda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked yesterday









ContronThePandaContronThePanda

613




613




New contributor




ContronThePanda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





ContronThePanda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






ContronThePanda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 7





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

    – wjandrea
    yesterday













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

    – Mark Wagner
    6 hours ago














  • 7





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

    – wjandrea
    yesterday













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

    – Mark Wagner
    6 hours ago








7




7





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

– wjandrea
yesterday







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

– wjandrea
yesterday















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

– Mark Wagner
6 hours ago





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

– Mark Wagner
6 hours ago










1 Answer
1






active

oldest

votes


















43














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





















  • 11





    Have an anecdote from 1985.

    – JdeBP
    yesterday











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
});


}
});






ContronThePanda is a new contributor. Be nice, and check out our Code of Conduct.










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









43














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





















  • 11





    Have an anecdote from 1985.

    – JdeBP
    yesterday
















43














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





















  • 11





    Have an anecdote from 1985.

    – JdeBP
    yesterday














43












43








43







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 20 hours ago

























answered yesterday









ilkkachuilkkachu

58.1k889164




58.1k889164








  • 11





    Have an anecdote from 1985.

    – JdeBP
    yesterday














  • 11





    Have an anecdote from 1985.

    – JdeBP
    yesterday








11




11





Have an anecdote from 1985.

– JdeBP
yesterday





Have an anecdote from 1985.

– JdeBP
yesterday










ContronThePanda is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















ContronThePanda is a new contributor. Be nice, and check out our Code of Conduct.













ContronThePanda is a new contributor. Be nice, and check out our Code of Conduct.












ContronThePanda is a new contributor. Be nice, and check out our Code of Conduct.
















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

Сан-Квентин

Алькесар

Josef Freinademetz