You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add zsh-specific operators and missing bash-shared operators
Add operator classification for >|, >>|, ;;, ;&, ;|, &| found in zsh
lex.c but previously returning WORDBREAK_UNKNOWN. This fixes redirect
detection for >| and >>| and pipeline splitting for all new list
operators. Also documents remaining zsh edge cases (RC_QUOTES inside
$'...', line continuation, INTERACTIVECOMMENTS, CSHJUNKIEQUOTES).
Assisted-by: Crush:glm-5.2
Copy file name to clipboardExpand all lines: skills/shlex/references/format-zsh.md
+19-4Lines changed: 19 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -82,11 +82,20 @@ Zsh has a 5-state model (vs bash's 2) because of the "full quoting" states where
82
82
83
83
## Operators
84
84
85
-
Same operator grammar as bash (`|`, `||`, `|&`, `&`, `;`, `&&`, `<`, `>`, `>>`, `<<<`, `<>`, `<&`, `&>`, `&>>`). See [format-bash.md](format-bash.md#operators-wordbreaktype) for the full table.
85
+
Same operator grammar as bash (`|`, `||`, `|&`, `&`, `;`, `&&`, `<`, `>`, `>>`, `>|`, `<<<`, `<>`, `<&`, `&>`, `&>>`, `;;`). See [format-bash.md](format-bash.md#operators-wordbreaktype) for the full table.
86
86
87
-
Zsh additions (not in bash):
88
-
-**`=(...)` process substitution** — `=` as a wordbreak followed by `(...)`.
89
-
-**Glob qualifiers**`(...)` after a path — these are word breaks but not operators in the pipeline sense.
|`;&`|`;&`|`WORDBREAK_LIST_FALLTHROUGH`| list (case fall-through) |
93
+
|`;\|`|`;\|`|`WORDBREAK_LIST_FALLTHROUGH_RETRY`| list (case fall-through with retry) |
94
+
|`&\|`|`&\|`|`WORDBREAK_LIST_ASYNC_ERRCHECK`| list (background with error check) |
95
+
96
+
Three of the four are pipeline delimiters (`IsPipelineDelimiter() == true`): `;&`, `;|`, `&|`. The exception is `>>|`, which is a redirect (`IsRedirect() == true`) and therefore not a pipeline delimiter.
97
+
98
+
Zsh also shares `>|` (force output redirect) and `;;` (case terminator) with bash — both are classified in `bashWordbreakType`.
90
99
91
100
## Comments
92
101
@@ -95,8 +104,14 @@ Zsh additions (not in bash):
95
104
## Edge Cases
96
105
97
106
-**`RC_QUOTES` off (default)**: `''` closes then reopens single quotes (same as bash).
107
+
-**`RC_QUOTES` inside `$'...'`**: zsh disables RC_QUOTES inside `$'...'` (ANSI-C quoting). The lexer cannot distinguish `$'...'` from `'...'`, so `$'it''s'` with `RC_QUOTES` would incorrectly produce `it's` instead of two segments. Unlikely in completion input.
98
108
-**Named directories**: zsh's `hash -d` creates `~name` expansions. Carapace handles this via `NamedDirectories.Matches` in `quoteValue`, not in the lexer.
99
109
-**`FULL_QUOTING_*_STATE` quirk**: when a word both starts and ends with the same quote, zsh places the trailing space *inside* the quote. Carapace forces nospace in these states.
110
+
-**`=(...)` process substitution**: `=` is a wordbreak (in `BASH_WORDBREAKS`) but classified as `WORDBREAK_UNKNOWN`, not a redirect.
111
+
-**Glob qualifiers**`(...)` after a path: these are word breaks but not operators in the pipeline sense.
112
+
-**Backslash-newline line continuation**: zsh consumes `\` + newline entirely (no character added). The lexer's `ESCAPING_STATE` adds the newline as a literal. Rare in single-line completion input.
113
+
-**`INTERACTIVECOMMENTS`**: `#` is only a comment in interactive mode when this option is set (on by default in modern zsh). The lexer always treats `#` as a comment.
114
+
-**`CSHJUNKIEQUOTES`**: with this tcsh-compatibility option, newlines inside single quotes close the quote. Very niche, not handled.
0 commit comments