Skip to content

Commit e2e23ca

Browse files
committed
Ensure terminal works *silently* with x-terminal-emulator set to xterm
1 parent 7ca324b commit e2e23ca

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/interceptors/terminal/fresh-terminal-interceptor.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ const getXTerminalCommand = async (command = 'x-terminal-emulator'): Promise<Spa
116116
// any of the args we want to use. To fix this, we parse --help to try and detect the underlying
117117
// terminal, and run it directly with the args we need.
118118
try {
119-
const { stdout } = await execAsync(`${command} --help`); // debian wrapper ignores --version
119+
// Run the command with -h to get some output we can use to infer the terminal itself.
120+
// --version would be nice, but the debian wrapper ignores it. --help isn't supported by xterm.
121+
const { stdout } = await execAsync(`${command} -h`);
120122
const helpOutput = stdout.toLowerCase().replace(/[^\w\d]+/g, ' ');
121123

122124
if (helpOutput.includes('gnome terminal') && await commandExists('gnome-terminal')) {
@@ -127,7 +129,12 @@ const getXTerminalCommand = async (command = 'x-terminal-emulator'): Promise<Spa
127129
return getKonsoleTerminalCommand();
128130
}
129131
} catch (e) {
130-
reportError(e);
132+
if (e.message.includes('rxvt')) {
133+
// Bizarrely, rxvt -h prints help but always returns a non-zero exit code.
134+
// Doesn't need any special arguments anyway though, so just ignore it
135+
} else {
136+
reportError(e);
137+
}
131138
}
132139

133140
// If there's an error, or we just don't recognize the console, give up & run it directly

0 commit comments

Comments
 (0)