Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a1da15e

Browse files
committed
Skip documentation for some builtins
Previously this was skipped as the parser logic was broken.
1 parent 4241bb6 commit a1da15e

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

‎server/src/util/__tests__/sh.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ describe('getDocumentation', () => {
2020
expect(lines[1]).toContain('list directory contents')
2121
})
2222

23+
it('skips documentation for some builtins', async () => {
24+
const result = await sh.getShellDocumentation({ word: 'else' })
25+
expect(result).toEqual(null)
26+
})
27+
2328
it('sanity checks the given word', async () => {
2429
await expect(sh.getShellDocumentation({ word: 'ls foo' })).rejects.toThrow()
2530
})

‎server/src/util/sh.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ export function execShellScript(body: string): Promise<string> {
2424
})
2525
}
2626

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+
2739
/**
2840
* Get documentation for the given word by usingZZ help and man.
2941
*/
@@ -36,6 +48,10 @@ export async function getShellDocumentationWithoutCache({
3648
throw new Error(`lookupDocumentation should be given a word, received "${word}"`)
3749
}
3850

51+
if (WORDS_WITHOUT_DOCUMENTATION.has(word)) {
52+
return null
53+
}
54+
3955
const DOCUMENTATION_COMMANDS = [
4056
{ type: 'help', command: `help ${word} | col -bx` },
4157
// We have experimented with setting MANWIDTH to different values for reformatting.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /