shell-integration: bash must be explicitly enabled

For now, bash integration must be explicitly enabled (by setting
`shell-integration = bash`). Our automatic shell integration requires
bash version 4 or later, and systems like macOS continue to ship bash
version 3 by default. This approach avoids the cost of performing a
runtime version check.
This commit is contained in:
Jon Parise
2024-06-03 20:32:05 -04:00
parent 29b3f9d528
commit 7d7fa46b0c
3 changed files with 14 additions and 1 deletions

View File

@@ -57,7 +57,11 @@ pub fn setup(
};
const result: ShellIntegration = shell: {
if (std.mem.eql(u8, "bash", exe)) {
// For now, bash integration must be explicitly enabled via force_shell.
// Our automatic shell integration requires bash version 4 or later,
// and systems like macOS continue to ship bash version 3 by default.
// This approach avoids the cost of performing a runtime version check.
if (std.mem.eql(u8, "bash", exe) and force_shell == .bash) {
const new_command = try setupBash(
alloc_arena,
command,
@@ -129,6 +133,8 @@ test "force shell" {
/// our script's responsibility (along with disabling POSIX
/// mode).
///
/// This approach requires bash version 4 or later.
///
/// This returns a new (allocated) shell command string that
/// enables the integration or null if integration failed.
fn setupBash(