То, что у вас есть, работает в моей системе.
user:~$ groups test;
test : test
user:~$ groups
user adm cdrom sudo dip www-data plugdev lpadmin sambashare davfs2 wireshark
user:~$ sudo usermod -a -G $(id -Gn | tr " " ",") test
user:~$ groups test
test : test adm cdrom sudo dip www-data plugdev lpadmin user sambashare davfs2 wireshark
Это зависит от эмулятора терминала.
xterm
сначала вызовет execvp(2)
с аргументами, переданными -e
, но если это не удастся и после -e
будет один аргумент command
, он также попытается $SHELL -c command
.
mlterm
и rxvt
просто выдадут ошибку, если execvp
не работает.
Если мой второй абзац вас не убедил, вы можете попробовать это:
$ mkdir /tmp/tbin; ln -s /usr/bin/vi '/tmp/tbin/echo hello; sleep 5'
$ PATH=$PATH:/tmp/tbin xterm -e 'echo hello; sleep 5'
Или посмотрите на источник .
В вашем примере, используя опцию -e
, xterm
запустит оболочку, это указано в руководстве.
Можно переопределить поиск оболочки по умолчанию в xterm, поэтому вы можете предоставить для этого свою собственную программу, но при переопределении оболочки вы не можете использовать опцию -e. Когда вы переопределяете оболочку, тогда ваша оболочка запускается(fork() + exec()
)непосредственно xterm.
Вот соответствующие разделы,
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.
и
-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.
И просто глядя на то, что вы выполняете,
"echo hello; sleep 5"
Эту строку анализирует оболочка, она использует переменную PATH
env для поиска двух команд и понимает, что это действительно две команды, разделенные точкой с запятой, xterm
этого не делает!