为此终端创建子进程时出错

There was an error creating the child process for this terminal

我正在尝试启动一个新的 gnome 终端并执行命令

当我执行gnome-terminal时,一个新终端顺利打开

现在当我运行这个

gnome-terminal -- "zsh; echo hello"

我希望打开带有 zsh 的新终端,并打印 hello。

但我得到的是一个新的终端:

There was an error creating the child process for this terminal
Failed to execute child process “zsh; echo hello” (No such file or directory)

一些重要的结果

请看


❯ gnome-terminal -e "echo hello"
# 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 --command "echo hello"
# Option “--command” 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 --window -- echo hello
❯ gnome-terminal --tab -- echo hello
❯ gnome-terminal --tab -- echo hello
❯ gnome-terminal --tab --wait  -- echo hello

我哪里出错了?如何完成我的预期工作,即启动一个打印有 hello 的新 zsh 终端,并等待下一个命令

发生的事情是您正在打开一个新终端,但是 运行在您的实际终端中使用这些命令。如果你想在新终端中 运行 这些命令,你必须指定 -x 选项,它表示它将在将打开的终端内执行命令行的其余部分。现在,您可以编写命令,但是您需要为 zsh 指定 -c 选项,以便 zsh 将第一个参数“The commands within commas”作为命令。现在终端将执行命令,并保持打开状态,不会闪烁。但是它不会有 shell,我猜你想继续写命令,所以你需要 exec zsh。就是这样。

会是这样的:

gnome-terminal --x zsh -c 'echo hello; exec zsh'

您的代码的第一行可能包含如下内容:

#!/usr/bin/expect -f

#!/bin/bash

确保此目录存在。例如,也许您是 运行 未安装时期望的程序。