Skip to content

fix(builtins): shift status, ~+/~- tilde prefixes, shopt -o - #2580

Merged
chaliy merged 2 commits into
mainfrom
claude/shell-gaps-2
Oct 7, 2026
Merged

chaliy merged 2 commits into
mainfrom
claude/shell-gaps-2

Conversation

@chaliy

@chaliy chaliy commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Requested by Михайло · project thread

What changed

  • shift N with N greater than $# shifts nothing and returns 1. shift abc and shift -1 fail with bash's messages.
  • ~+ expands to PWD and ~- to OLDPWD, including ~+/x. ~- stays literal when OLDPWD is unset.
  • shopt -o works with -s, -u, -q and -p on set -o option names.

Why

Pseudo-linus oracle gaps: shift return code, tilde ~+/~-, and shopt -o.

Before / After

Script Before After (= bash 5.2)
set -- a; shift 2; echo $? $# 0 0 1 1
cd /tmp; cd /; echo ~+ ~- ~+ ~- / /tmp
shopt -o noglob shopt: -o: invalid option noglob off

New spec shell-misc-gaps.test.sh has 4 cases, all verified against bash.

Risk

Low. Each change is local to its builtin or to tilde prefix handling. A shift past the end used to clear the arguments; now it keeps them, as bash does.

Checklist

  • Tests (spec, verified against bash)
  • cargo fmt, cargo clippy -D warnings
  • lib, integration and bash_comparison tests
  • Docs (compatibility.md) and knowledge log updated

https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA


Generated by Claude Code

`shift N` past `$#` now fails with status 1 without shifting, and bad
counts report bash's errors. `~+` and `~-` expand to PWD and OLDPWD.
`shopt -o` acts on `set -o` option names.

Claude-Session: https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA
@chaliy chaliy self-assigned this Oct 7, 2026
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit af0673c Commit Preview URL

Branch Preview URL
Oct 07 2026, 05:41 PM

@chaliy
chaliy merged commit ebfd3fc into main Oct 7, 2026
47 checks passed
@chaliy
chaliy deleted the claude/shell-gaps-2 branch October 7, 2026 18:08
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.

1 participant