首页 > 解决方案 > 在 gnome 终端的新选项卡中运行脚本

问题描述

到目前为止,我有这个有效的命令

gnome-terminal --tab -e '/bin/bash -c "ls";bash'

但有一个警告

# Option “-e” is deprecated and might be removed in a later version of gnome-terminal.
# Use “-- ” to terminate the options and put the command line to execute after it.

当我把它改成

gnome-terminal --tab -- '/bin/bash -c "ls";bash'

新标签失败

There was an error creating the child process for this terminal
Failed to execute child process “/bin/bash -c "ls";bash” (No such file or directory)

标签: bashshellubuntugnome-terminal

解决方案


The reason that:

gnome-terminal --tab -- '/bin/bash -c "ls";bash'

Fails is that it is looking for a program with that as its name. This is an instance of chain loading where the rest of the arguments are passed as is to exec. Those first argument is the name of the program. With this quoting it receives the entire command and options as a single program name.

Change the quoting to:

gnome-terminal --tab -- /bin/bash -c "ls;bash"

推荐阅读