mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
Merge pull request #1765 from jparise/bash-command-option
shell-integration: handle 'bash -c command'
This commit is contained in:
@ -156,8 +156,6 @@ fn setupBash(
|
||||
|
||||
// Some additional cases we don't yet cover:
|
||||
//
|
||||
// - If the `c` shell option is set, interactive mode is disabled, so skip
|
||||
// loading our shell integration.
|
||||
// - If additional file arguments are provided (after a `-` or `--` flag),
|
||||
// and the `i` shell option isn't being explicitly set, we can assume a
|
||||
// non-interactive shell session and skip loading our shell integration.
|
||||
@ -173,6 +171,12 @@ fn setupBash(
|
||||
if (iter.next()) |rcfile| {
|
||||
try env.put("GHOSTTY_BASH_RCFILE", rcfile);
|
||||
}
|
||||
} else if (arg.len > 1 and arg[0] == '-' and arg[1] != '-') {
|
||||
// '-c command' is always non-interactive
|
||||
if (std.mem.indexOfScalar(u8, arg, 'c') != null) {
|
||||
return null;
|
||||
}
|
||||
try args.append(arg);
|
||||
} else {
|
||||
try args.append(arg);
|
||||
}
|
||||
@ -297,6 +301,17 @@ test "bash: rcfile" {
|
||||
}
|
||||
}
|
||||
|
||||
test "bash: -c command" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
|
||||
var env = EnvMap.init(alloc);
|
||||
defer env.deinit();
|
||||
|
||||
try testing.expect(try setupBash(alloc, "bash -c script.sh", ".", &env) == null);
|
||||
try testing.expect(try setupBash(alloc, "bash -ic script.sh", ".", &env) == null);
|
||||
}
|
||||
|
||||
test "bash: HISTFILE" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
|
Reference in New Issue
Block a user