File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,11 @@ describe('getDocumentation', () => {
20
20
expect ( lines [ 1 ] ) . toContain ( 'list directory contents' )
21
21
} )
22
22
23
+ it ( 'skips documentation for some builtins' , async ( ) => {
24
+ const result = await sh . getShellDocumentation ( { word : 'else' } )
25
+ expect ( result ) . toEqual ( null )
26
+ } )
27
+
23
28
it ( 'sanity checks the given word' , async ( ) => {
24
29
await expect ( sh . getShellDocumentation ( { word : 'ls foo' } ) ) . rejects . toThrow ( )
25
30
} )
Original file line number Diff line number Diff line change @@ -24,6 +24,18 @@ export function execShellScript(body: string): Promise<string> {
24
24
} )
25
25
}
26
26
27
+ // Currently only reserved words where documentation doesn't make sense.
28
+ // At least on OS X these just return the builtin man. On ubuntu there
29
+ // are no documentaiton for them.
30
+ const WORDS_WITHOUT_DOCUMENTATION = new Set ( [
31
+ 'else' ,
32
+ 'fi' ,
33
+ 'then' ,
34
+ 'esac' ,
35
+ 'elif' ,
36
+ 'done' ,
37
+ ] )
38
+
27
39
/**
28
40
* Get documentation for the given word by usingZZ help and man.
29
41
*/
@@ -36,6 +48,10 @@ export async function getShellDocumentationWithoutCache({
36
48
throw new Error ( `lookupDocumentation should be given a word, received "${ word } "` )
37
49
}
38
50
51
+ if ( WORDS_WITHOUT_DOCUMENTATION . has ( word ) ) {
52
+ return null
53
+ }
54
+
39
55
const DOCUMENTATION_COMMANDS = [
40
56
{ type : 'help' , command : `help ${ word } | col -bx` } ,
41
57
// We have experimented with setting MANWIDTH to different values for reformatting.
You can’t perform that action at this time.
0 commit comments