File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,6 +31,25 @@ describe("completion-cli", () => {
3131 expect ( script ) . toContain ( "--force[Force the action]" ) ;
3232 } ) ;
3333
34+ it ( "escapes zsh descriptions that contain backticks" , ( ) => {
35+ const program = new Command ( ) ;
36+ program . name ( "openclaw" ) ;
37+ program
38+ . command ( "models" )
39+ . description ( "Model commands" )
40+ . option ( "--status-json" , "Output JSON (alias for `models status --json`)" ) ;
41+ program
42+ . command ( "hooks" )
43+ . description ( "Hook commands" )
44+ . command ( "install" )
45+ . description ( "Deprecated: install via `openclaw plugins install`" ) ;
46+
47+ const script = getCompletionScript ( "zsh" , program ) ;
48+
49+ expect ( script ) . toContain ( "--status-json[Output JSON (alias for \\`models status --json\\`)]" ) ;
50+ expect ( script ) . toContain ( "install[Deprecated: install via \\`openclaw plugins install\\`]" ) ;
51+ } ) ;
52+
3453 it ( "defers zsh registration until compinit is available" , async ( ) => {
3554 if ( process . platform === "win32" ) {
3655 return ;
Original file line number Diff line number Diff line change @@ -195,6 +195,7 @@ function generateZshArgs(cmd: Command): string {
195195 const short = flags . find ( ( f ) => f . startsWith ( "-" ) && ! f . startsWith ( "--" ) ) ;
196196 const desc = opt . description
197197 . replace ( / \\ / g, "\\\\" )
198+ . replace ( / ` / g, "\\`" )
198199 . replace ( / " / g, '\\"' )
199200 . replace ( / ' / g, "'\\''" )
200201 . replace ( / \[ / g, "\\[" )
@@ -213,6 +214,7 @@ function generateZshSubcmdList(cmd: Command): string {
213214 const desc = c
214215 . description ( )
215216 . replace ( / \\ / g, "\\\\" )
217+ . replace ( / ` / g, "\\`" )
216218 . replace ( / ' / g, "'\\''" )
217219 . replace ( / \[ / g, "\\[" )
218220 . replace ( / \] / g, "\\]" ) ;
You can’t perform that action at this time.
0 commit comments