@@ -78,7 +78,22 @@ describe('shell integration tests', () => {
7878 // If we get here, syntax is valid
7979 expect ( true ) . toBe ( true ) ;
8080 } catch ( error ) {
81- throw new Error ( `Bash script has syntax errors: ${ error } ` ) ;
81+ const errorMessage =
82+ error instanceof Error ? error . message : String ( error ) ;
83+
84+ // Provide helpful error message about bash-completion dependency
85+ const helpMessage = `
86+ Bash script has syntax errors: ${ errorMessage }
87+
88+ This might be due to missing bash-completion dependency.
89+ To fix this, install bash-completion@2:
90+
91+ brew install bash-completion@2
92+
93+ Then source the completion in your shell profile:
94+ echo 'source $(brew --prefix)/share/bash-completion/bash_completion' >> ~/.bashrc
95+ ` ;
96+ throw new Error ( helpMessage ) ;
8297 } finally {
8398 // Clean up
8499 await unlink ( scriptPath ) . catch ( ( ) => { } ) ;
@@ -224,14 +239,15 @@ describe('shell integration tests', () => {
224239
225240 // Test for potential bash issues (related to the user's problem)
226241 describe ( 'bash-specific issue detection' , ( ) => {
227- it ( 'should generate bash script with proper escaping ' , async ( ) => {
242+ it ( 'should generate bash script with proper syntax (requires bash-completion@2) ' , async ( ) => {
228243 const command = `pnpm tsx examples/demo.${ cliTool } .ts complete bash` ;
229244 const { stdout } = await exec ( command ) ;
230245
231- // Check for the actual problematic bash syntax in the requestComp assignment
232- expect ( stdout ) . not . toMatch ( / r e q u e s t C o m p = " [ ^ " ] * \$ \ {w o r d s \[ @ \ ]: 1 \} / ) ; // Should not use ${words[@]:1 } in requestComp
246+ // Check that it uses the correct ${words[ @]:1 } syntax
247+ expect ( stdout ) . toContain ( '$ {words[@ ]:1}' ) ; // Should use ${words[@]:1 } (requires bash-completion@2)
233248 expect ( stdout ) . toContain ( 'requestComp=' ) ; // Should have proper variable assignment
234249 expect ( stdout ) . toContain ( 'complete -F' ) ; // Should register completion properly
250+ expect ( stdout ) . toContain ( '_get_comp_words_by_ref' ) ; // Should use bash-completion functions
235251 } ) ;
236252
237253 it ( 'should generate bash script that handles empty parameters correctly' , async ( ) => {
0 commit comments