Does a terminal emulator execute a program always indirectly via shell?
up vote
1
down vote
favorite
Does a terminal emulator execute a program always indirectly via shell?
For example, when we open a terminal emulator window, it automatically executes a shell, and we can only type commands in the shell.
For example, when running a program directly on a terminal emulator, such as
xterm -e "echo hello; sleep 5"
Does xterm
execute the program, indirectly via shell, or directly without shell?
xterm terminal-emulator
add a comment |
up vote
1
down vote
favorite
Does a terminal emulator execute a program always indirectly via shell?
For example, when we open a terminal emulator window, it automatically executes a shell, and we can only type commands in the shell.
For example, when running a program directly on a terminal emulator, such as
xterm -e "echo hello; sleep 5"
Does xterm
execute the program, indirectly via shell, or directly without shell?
xterm terminal-emulator
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Does a terminal emulator execute a program always indirectly via shell?
For example, when we open a terminal emulator window, it automatically executes a shell, and we can only type commands in the shell.
For example, when running a program directly on a terminal emulator, such as
xterm -e "echo hello; sleep 5"
Does xterm
execute the program, indirectly via shell, or directly without shell?
xterm terminal-emulator
Does a terminal emulator execute a program always indirectly via shell?
For example, when we open a terminal emulator window, it automatically executes a shell, and we can only type commands in the shell.
For example, when running a program directly on a terminal emulator, such as
xterm -e "echo hello; sleep 5"
Does xterm
execute the program, indirectly via shell, or directly without shell?
xterm terminal-emulator
xterm terminal-emulator
edited Nov 28 at 15:19
slm♦
245k66505671
245k66505671
asked Nov 28 at 0:13
Tim
25.1k72243444
25.1k72243444
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
up vote
4
down vote
accepted
It depends on the terminal emulator.
xterm
will first call execvp(2)
with the arguments given to -e
, but if that fails and there is a single command
argument following -e
, it will also try $SHELL -c command
.
mlterm
and rxvt
will just error out if the execvp
fails.
If my second paragraph didn't convince you, you can try this:
$ mkdir /tmp/tbin; ln -s /usr/bin/vi '/tmp/tbin/echo hello; sleep 5'
$ PATH=$PATH:/tmp/tbin xterm -e 'echo hello; sleep 5'
Or look at the source.
add a comment |
up vote
2
down vote
With your example, using the -e
option, then xterm
will start a shell, the manual states this.
It is possible to override xterm's default search for a shell, so you could supply your own program for this, but when you override the shell you cannot use the -e option. When you override the shell, then the your shell is run (fork() + exec()
) directly by xterm.
Here are the relevant sections,
One parameter (after all options) may be given. That overrides xterm's built-in choice of
shell program. Normally xterm checks the SHELL variable. If that is not set, xterm tries
to use the shell program specified in the password file. If that is not set, xterm uses
/bin/sh. If the parameter is not a relative path, i.e., beginning with “./” or “../”, xterm
looks for the file in the user's PATH. In either case, it constructs an absolute path. The
-e option cannot be used with this parameter since it uses all parameters following the
option.
and
-e program [ arguments ... ]
This option specifies the program (and its command line arguments) to be run in the
xterm window. It also sets the window title and icon name to be the basename of the
program being executed if neither -T nor -n are given on the command line. This
must be the last option on the command line.
And just looking at what you are executing,
"echo hello; sleep 5"
It's the shell which parses that string, it uses the PATH
env variable to find the two commands, and realises that it is indeed two commands separated with the semi colon, xterm
doesn't do that!
Thanks. Very nice.
– Tim
2 days ago
add a comment |
up vote
0
down vote
According to the manual, you can disable login shell with parameter +ls
:
+ls This option indicates that the shell that is started should not
be a login shell (i.e., it will be a normal “subshell”).
So xterm -e "echo hello"
spawns a shell, but xterm +ls -e "echo hello"
does not.
xterm +ls -e "echo hello"
executesecho hello
indirectly by a shell, doesn't it?
– Tim
Nov 28 at 0:50
That is,xterm +ls -e "echo hello"
executes a shell to executeecho hello
, doesn't it?
– Tim
Nov 28 at 0:59
2
You're confusing "login shell" vs. "non-login shell" with having a shell at all...xterm +ls -e '...'
still runs a shell, just not a login shell. You can easily check that by running a command that needs the shell (like something with;
) or by using, say,ps -p $$
– Filipe Brandenburger
Nov 28 at 1:28
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
It depends on the terminal emulator.
xterm
will first call execvp(2)
with the arguments given to -e
, but if that fails and there is a single command
argument following -e
, it will also try $SHELL -c command
.
mlterm
and rxvt
will just error out if the execvp
fails.
If my second paragraph didn't convince you, you can try this:
$ mkdir /tmp/tbin; ln -s /usr/bin/vi '/tmp/tbin/echo hello; sleep 5'
$ PATH=$PATH:/tmp/tbin xterm -e 'echo hello; sleep 5'
Or look at the source.
add a comment |
up vote
4
down vote
accepted
It depends on the terminal emulator.
xterm
will first call execvp(2)
with the arguments given to -e
, but if that fails and there is a single command
argument following -e
, it will also try $SHELL -c command
.
mlterm
and rxvt
will just error out if the execvp
fails.
If my second paragraph didn't convince you, you can try this:
$ mkdir /tmp/tbin; ln -s /usr/bin/vi '/tmp/tbin/echo hello; sleep 5'
$ PATH=$PATH:/tmp/tbin xterm -e 'echo hello; sleep 5'
Or look at the source.
add a comment |
up vote
4
down vote
accepted
up vote
4
down vote
accepted
It depends on the terminal emulator.
xterm
will first call execvp(2)
with the arguments given to -e
, but if that fails and there is a single command
argument following -e
, it will also try $SHELL -c command
.
mlterm
and rxvt
will just error out if the execvp
fails.
If my second paragraph didn't convince you, you can try this:
$ mkdir /tmp/tbin; ln -s /usr/bin/vi '/tmp/tbin/echo hello; sleep 5'
$ PATH=$PATH:/tmp/tbin xterm -e 'echo hello; sleep 5'
Or look at the source.
It depends on the terminal emulator.
xterm
will first call execvp(2)
with the arguments given to -e
, but if that fails and there is a single command
argument following -e
, it will also try $SHELL -c command
.
mlterm
and rxvt
will just error out if the execvp
fails.
If my second paragraph didn't convince you, you can try this:
$ mkdir /tmp/tbin; ln -s /usr/bin/vi '/tmp/tbin/echo hello; sleep 5'
$ PATH=$PATH:/tmp/tbin xterm -e 'echo hello; sleep 5'
Or look at the source.
edited Nov 28 at 3:05
answered Nov 28 at 2:47
mosvy
5,011323
5,011323
add a comment |
add a comment |
up vote
2
down vote
With your example, using the -e
option, then xterm
will start a shell, the manual states this.
It is possible to override xterm's default search for a shell, so you could supply your own program for this, but when you override the shell you cannot use the -e option. When you override the shell, then the your shell is run (fork() + exec()
) directly by xterm.
Here are the relevant sections,
One parameter (after all options) may be given. That overrides xterm's built-in choice of
shell program. Normally xterm checks the SHELL variable. If that is not set, xterm tries
to use the shell program specified in the password file. If that is not set, xterm uses
/bin/sh. If the parameter is not a relative path, i.e., beginning with “./” or “../”, xterm
looks for the file in the user's PATH. In either case, it constructs an absolute path. The
-e option cannot be used with this parameter since it uses all parameters following the
option.
and
-e program [ arguments ... ]
This option specifies the program (and its command line arguments) to be run in the
xterm window. It also sets the window title and icon name to be the basename of the
program being executed if neither -T nor -n are given on the command line. This
must be the last option on the command line.
And just looking at what you are executing,
"echo hello; sleep 5"
It's the shell which parses that string, it uses the PATH
env variable to find the two commands, and realises that it is indeed two commands separated with the semi colon, xterm
doesn't do that!
Thanks. Very nice.
– Tim
2 days ago
add a comment |
up vote
2
down vote
With your example, using the -e
option, then xterm
will start a shell, the manual states this.
It is possible to override xterm's default search for a shell, so you could supply your own program for this, but when you override the shell you cannot use the -e option. When you override the shell, then the your shell is run (fork() + exec()
) directly by xterm.
Here are the relevant sections,
One parameter (after all options) may be given. That overrides xterm's built-in choice of
shell program. Normally xterm checks the SHELL variable. If that is not set, xterm tries
to use the shell program specified in the password file. If that is not set, xterm uses
/bin/sh. If the parameter is not a relative path, i.e., beginning with “./” or “../”, xterm
looks for the file in the user's PATH. In either case, it constructs an absolute path. The
-e option cannot be used with this parameter since it uses all parameters following the
option.
and
-e program [ arguments ... ]
This option specifies the program (and its command line arguments) to be run in the
xterm window. It also sets the window title and icon name to be the basename of the
program being executed if neither -T nor -n are given on the command line. This
must be the last option on the command line.
And just looking at what you are executing,
"echo hello; sleep 5"
It's the shell which parses that string, it uses the PATH
env variable to find the two commands, and realises that it is indeed two commands separated with the semi colon, xterm
doesn't do that!
Thanks. Very nice.
– Tim
2 days ago
add a comment |
up vote
2
down vote
up vote
2
down vote
With your example, using the -e
option, then xterm
will start a shell, the manual states this.
It is possible to override xterm's default search for a shell, so you could supply your own program for this, but when you override the shell you cannot use the -e option. When you override the shell, then the your shell is run (fork() + exec()
) directly by xterm.
Here are the relevant sections,
One parameter (after all options) may be given. That overrides xterm's built-in choice of
shell program. Normally xterm checks the SHELL variable. If that is not set, xterm tries
to use the shell program specified in the password file. If that is not set, xterm uses
/bin/sh. If the parameter is not a relative path, i.e., beginning with “./” or “../”, xterm
looks for the file in the user's PATH. In either case, it constructs an absolute path. The
-e option cannot be used with this parameter since it uses all parameters following the
option.
and
-e program [ arguments ... ]
This option specifies the program (and its command line arguments) to be run in the
xterm window. It also sets the window title and icon name to be the basename of the
program being executed if neither -T nor -n are given on the command line. This
must be the last option on the command line.
And just looking at what you are executing,
"echo hello; sleep 5"
It's the shell which parses that string, it uses the PATH
env variable to find the two commands, and realises that it is indeed two commands separated with the semi colon, xterm
doesn't do that!
With your example, using the -e
option, then xterm
will start a shell, the manual states this.
It is possible to override xterm's default search for a shell, so you could supply your own program for this, but when you override the shell you cannot use the -e option. When you override the shell, then the your shell is run (fork() + exec()
) directly by xterm.
Here are the relevant sections,
One parameter (after all options) may be given. That overrides xterm's built-in choice of
shell program. Normally xterm checks the SHELL variable. If that is not set, xterm tries
to use the shell program specified in the password file. If that is not set, xterm uses
/bin/sh. If the parameter is not a relative path, i.e., beginning with “./” or “../”, xterm
looks for the file in the user's PATH. In either case, it constructs an absolute path. The
-e option cannot be used with this parameter since it uses all parameters following the
option.
and
-e program [ arguments ... ]
This option specifies the program (and its command line arguments) to be run in the
xterm window. It also sets the window title and icon name to be the basename of the
program being executed if neither -T nor -n are given on the command line. This
must be the last option on the command line.
And just looking at what you are executing,
"echo hello; sleep 5"
It's the shell which parses that string, it uses the PATH
env variable to find the two commands, and realises that it is indeed two commands separated with the semi colon, xterm
doesn't do that!
edited 2 days ago
answered Nov 28 at 15:48
X Tian
7,57111936
7,57111936
Thanks. Very nice.
– Tim
2 days ago
add a comment |
Thanks. Very nice.
– Tim
2 days ago
Thanks. Very nice.
– Tim
2 days ago
Thanks. Very nice.
– Tim
2 days ago
add a comment |
up vote
0
down vote
According to the manual, you can disable login shell with parameter +ls
:
+ls This option indicates that the shell that is started should not
be a login shell (i.e., it will be a normal “subshell”).
So xterm -e "echo hello"
spawns a shell, but xterm +ls -e "echo hello"
does not.
xterm +ls -e "echo hello"
executesecho hello
indirectly by a shell, doesn't it?
– Tim
Nov 28 at 0:50
That is,xterm +ls -e "echo hello"
executes a shell to executeecho hello
, doesn't it?
– Tim
Nov 28 at 0:59
2
You're confusing "login shell" vs. "non-login shell" with having a shell at all...xterm +ls -e '...'
still runs a shell, just not a login shell. You can easily check that by running a command that needs the shell (like something with;
) or by using, say,ps -p $$
– Filipe Brandenburger
Nov 28 at 1:28
add a comment |
up vote
0
down vote
According to the manual, you can disable login shell with parameter +ls
:
+ls This option indicates that the shell that is started should not
be a login shell (i.e., it will be a normal “subshell”).
So xterm -e "echo hello"
spawns a shell, but xterm +ls -e "echo hello"
does not.
xterm +ls -e "echo hello"
executesecho hello
indirectly by a shell, doesn't it?
– Tim
Nov 28 at 0:50
That is,xterm +ls -e "echo hello"
executes a shell to executeecho hello
, doesn't it?
– Tim
Nov 28 at 0:59
2
You're confusing "login shell" vs. "non-login shell" with having a shell at all...xterm +ls -e '...'
still runs a shell, just not a login shell. You can easily check that by running a command that needs the shell (like something with;
) or by using, say,ps -p $$
– Filipe Brandenburger
Nov 28 at 1:28
add a comment |
up vote
0
down vote
up vote
0
down vote
According to the manual, you can disable login shell with parameter +ls
:
+ls This option indicates that the shell that is started should not
be a login shell (i.e., it will be a normal “subshell”).
So xterm -e "echo hello"
spawns a shell, but xterm +ls -e "echo hello"
does not.
According to the manual, you can disable login shell with parameter +ls
:
+ls This option indicates that the shell that is started should not
be a login shell (i.e., it will be a normal “subshell”).
So xterm -e "echo hello"
spawns a shell, but xterm +ls -e "echo hello"
does not.
answered Nov 28 at 0:18
Ipor Sircer
10.3k11024
10.3k11024
xterm +ls -e "echo hello"
executesecho hello
indirectly by a shell, doesn't it?
– Tim
Nov 28 at 0:50
That is,xterm +ls -e "echo hello"
executes a shell to executeecho hello
, doesn't it?
– Tim
Nov 28 at 0:59
2
You're confusing "login shell" vs. "non-login shell" with having a shell at all...xterm +ls -e '...'
still runs a shell, just not a login shell. You can easily check that by running a command that needs the shell (like something with;
) or by using, say,ps -p $$
– Filipe Brandenburger
Nov 28 at 1:28
add a comment |
xterm +ls -e "echo hello"
executesecho hello
indirectly by a shell, doesn't it?
– Tim
Nov 28 at 0:50
That is,xterm +ls -e "echo hello"
executes a shell to executeecho hello
, doesn't it?
– Tim
Nov 28 at 0:59
2
You're confusing "login shell" vs. "non-login shell" with having a shell at all...xterm +ls -e '...'
still runs a shell, just not a login shell. You can easily check that by running a command that needs the shell (like something with;
) or by using, say,ps -p $$
– Filipe Brandenburger
Nov 28 at 1:28
xterm +ls -e "echo hello"
executes echo hello
indirectly by a shell, doesn't it?– Tim
Nov 28 at 0:50
xterm +ls -e "echo hello"
executes echo hello
indirectly by a shell, doesn't it?– Tim
Nov 28 at 0:50
That is,
xterm +ls -e "echo hello"
executes a shell to execute echo hello
, doesn't it?– Tim
Nov 28 at 0:59
That is,
xterm +ls -e "echo hello"
executes a shell to execute echo hello
, doesn't it?– Tim
Nov 28 at 0:59
2
2
You're confusing "login shell" vs. "non-login shell" with having a shell at all...
xterm +ls -e '...'
still runs a shell, just not a login shell. You can easily check that by running a command that needs the shell (like something with ;
) or by using, say, ps -p $$
– Filipe Brandenburger
Nov 28 at 1:28
You're confusing "login shell" vs. "non-login shell" with having a shell at all...
xterm +ls -e '...'
still runs a shell, just not a login shell. You can easily check that by running a command that needs the shell (like something with ;
) or by using, say, ps -p $$
– Filipe Brandenburger
Nov 28 at 1:28
add a comment |
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f484548%2fdoes-a-terminal-emulator-execute-a-program-always-indirectly-via-shell%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