Executable file named 'test' is in $PATH but won't run
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:
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.
Running
which test
still returns the correct file path.Probably the weirdest of all - the script works fine when run through
strace
. I tried usingstrace
to see if I could figure out what was going on but when I ran it withstrace
, it worked as expected with 0 issues.
bash shell-script path executable strace
New contributor
add a comment |
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:
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.
Running
which test
still returns the correct file path.Probably the weirdest of all - the script works fine when run through
strace
. I tried usingstrace
to see if I could figure out what was going on but when I ran it withstrace
, it worked as expected with 0 issues.
bash shell-script path executable strace
New contributor
7
Usetype
, notwhich
. 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
add a comment |
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:
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.
Running
which test
still returns the correct file path.Probably the weirdest of all - the script works fine when run through
strace
. I tried usingstrace
to see if I could figure out what was going on but when I ran it withstrace
, it worked as expected with 0 issues.
bash shell-script path executable strace
New contributor
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:
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.
Running
which test
still returns the correct file path.Probably the weirdest of all - the script works fine when run through
strace
. I tried usingstrace
to see if I could figure out what was going on but when I ran it withstrace
, it worked as expected with 0 issues.
bash shell-script path executable strace
bash shell-script path executable strace
New contributor
New contributor
edited 3 hours ago
ivan_pozdeev
36619
36619
New contributor
asked yesterday
ContronThePandaContronThePanda
613
613
New contributor
New contributor
7
Usetype
, notwhich
. 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
add a comment |
7
Usetype
, notwhich
. 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
add a comment |
1 Answer
1
active
oldest
votes
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?
11
Have an anecdote from 1985.
– JdeBP
yesterday
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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?
11
Have an anecdote from 1985.
– JdeBP
yesterday
add a comment |
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?
11
Have an anecdote from 1985.
– JdeBP
yesterday
add a comment |
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?
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?
edited 19 hours ago
answered yesterday
ilkkachuilkkachu
58.1k889164
58.1k889164
11
Have an anecdote from 1985.
– JdeBP
yesterday
add a comment |
11
Have an anecdote from 1985.
– JdeBP
yesterday
11
11
Have an anecdote from 1985.
– JdeBP
yesterday
Have an anecdote from 1985.
– JdeBP
yesterday
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
7
Use
type
, notwhich
. 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