Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bash: handle additional command arguments #5319

Merged
merged 1 commit into from
Jan 24, 2025

Conversation

jparise
Copy link
Collaborator

@jparise jparise commented Jan 23, 2025

A '-' or '--' argument signals the end of bash's own options. All remaining arguments are treated as filenames and arguments. We shouldn't perform any additional argument processing once we see this signal.

We could also assume a non-interactive shell session in this case unless the '-i' (interactive) shell option has been explicitly specified, but let's wait on that until we know that doing so would solve a real user problem (and avoid any false negatives).

A '-' or '--' argument signals the end of bash's own options. All
remaining arguments are treated as filenames and arguments. We shouldn't
perform any additional argument processing once we see this signal.

We could also assume a non-interactive shell session in this case unless
the '-i' (interactive) shell option has been explicitly specified, but
let's wait on that until we know that doing so would solve a real user
problem (and avoid any false negatives).
@@ -203,8 +203,6 @@ test "setup features" {
/// our script's responsibility (along with disabling POSIX
/// mode).
///
/// This approach requires bash version 4 or later.
Copy link
Collaborator Author

@jparise jparise Jan 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was never quite true. The problem was with Apple's patched version of bash 3.2 (#2966).

while (iter.next()) |remaining_arg| {
try args.append(remaining_arg);
}
break;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The loop will naturally terminate because we entirely consume the iterator above, but I made this explicit with the break.

@mitchellh mitchellh merged commit 9b30eb8 into ghostty-org:main Jan 24, 2025
30 checks passed
@github-actions github-actions bot added this to the 1.1.0 milestone Jan 24, 2025
@jparise jparise deleted the bash-additional-arguments branch January 24, 2025 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants