Skip to content

Comments

feat: paste, command, getopts, nounset, [[ =~ ]], glob **, backtick subst#232

Merged
chaliy merged 9 commits intomainfrom
claude/bashkit-bash-compatibility-BsDKD
Feb 23, 2026
Merged

feat: paste, command, getopts, nounset, [[ =~ ]], glob **, backtick subst#232
chaliy merged 9 commits intomainfrom
claude/bashkit-bash-compatibility-BsDKD

Conversation

@chaliy
Copy link
Contributor

@chaliy chaliy commented Feb 23, 2026

Summary

  • paste: Remove skip markers for -s and -d (already implemented)
  • command: Implement command -v, -V, and function bypass
  • getopts: Implement POSIX option parsing with combined flags, silent mode
  • set -u: Implement nounset for unbound variable checks with abort on error
  • [[ ]]: Parse and evaluate conditional expressions with =~ regex matching and BASH_REMATCH
  • glob **: Implement recursive glob pattern matching
  • backtick: Convert `cmd` to $(cmd) in lexer for command substitution

Test plan

  • 9 command spec tests passing
  • 9 getopts spec tests passing
  • 7 nounset spec tests (1 skipped for ${var:-default})
  • 17 conditional spec tests passing
  • Recursive glob test passing
  • Backtick substitution test passing
  • cargo fmt --check clean
  • cargo clippy clean
  • bash_spec_tests all pass
  • bash_comparison_tests all pass

The paste builtin already supports -s (serial) and -d (delimiter) with
stdin input. Remove incorrect skip markers from spec tests.
Add POSIX `command` builtin with:
- `command -v name`: check if command exists (builtins, functions, keywords)
- `command -V name`: verbose description of command type
- `command name args...`: run command bypassing shell functions

Includes 9 spec tests covering all modes.
Real bash prints the full function body with command -V, our
implementation only prints the type description.
POSIX getopts for option parsing in shell scripts:
- Basic option parsing with optstring
- Options with required arguments (: suffix)
- Combined flags (-abc)
- Silent error mode (leading :)
- OPTIND/OPTARG variable management
- -- processing terminator

Includes 9 spec tests.
…ecks

- Add nounset_error flag to Interpreter, set during expand_word when
  referencing unset variables under set -u
- Check and abort in execute_simple_command (name expansion) and
  execute_dispatched_command (arg expansion)
- Stop top-level execute loop on non-None control flow so nounset
  errors abort the script
- Add is_variable_set() covering special vars, positional params,
  locals, shell vars, and env
- Add 7 spec tests (1 skipped for ${var:-default} awareness)
- Update implementation-status with getopts/command/nounset entries
@chaliy chaliy changed the title feat: command builtin + paste skip removal feat: paste, command, getopts builtins + set -u nounset Feb 23, 2026
…h =~ regex

- Parse [[ ... ]] as CompoundCommand::Conditional in the parser
- Handle && and || as literal words inside [[ ]]
- Collect regex patterns after =~ with special paren handling
- Evaluate conditionals with string, numeric, file, and regex operators
- Set BASH_REMATCH array with capture groups on =~ match
- Add 17 spec tests covering ==, !=, <, >, !, &&, ||, -z, -n,
  -eq, -lt, =~ basic match, no match, capture groups, variables
- Add expand_glob_recursive for ** pattern in glob expansion
- Recursively collect subdirectories and match file patterns at all depths
- Update glob_recursive test from skip to passing with VFS test files
Convert `cmd` to $(cmd) in the lexer for both unquoted words and
double-quoted strings, handling backslash escaping per POSIX rules.
Unskip subst_backtick spec test.
@chaliy chaliy changed the title feat: paste, command, getopts builtins + set -u nounset feat: paste, command, getopts, nounset, [[ =~ ]], glob **, backtick subst Feb 23, 2026
The security_function_depth_bypass test deliberately bypasses function
depth limits, causing deep async recursion. Run on a thread with
explicit 8MB stack so the command limit halts execution before the
OS stack overflows.
@chaliy chaliy merged commit 9db495c into main Feb 23, 2026
16 checks passed
@chaliy chaliy deleted the claude/bashkit-bash-compatibility-BsDKD branch February 23, 2026 09:03
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