Mercurial > vim
annotate runtime/ftplugin/sh.vim @ 35122:739aaccbca74
runtime(sh,zsh): clear $MANPAGER in ftplugin before shelling out
Commit: https://github.com/vim/vim/commit/8d8cb45756cb7e6fda17013b8347be3a11b29610
Author: D. Ben Knoble <ben.knoble+github@gmail.com>
Date: Mon May 6 19:52:53 2024 +0200
runtime(sh,zsh): clear $MANPAGER in ftplugin before shelling out
Say you use Vim and set MANPAGER='vim -M +MANPAGER --not-a-term -'; then
:{Zs,S}hKeywordPrg (or K) will crap out and spew terminal garbage into
less when bash's "help" fails. This was introduced by 2f25e40b1
(runtime: configure keywordpg for some file types (#5566), 2023-08-23)
and may be present in other files touched by that commit.
Make the "man" invocation sensible by unsetting MANPAGER in the
environment.
Note that changing MANPAGER for `:terminal` is not needed; Vim within
Vim is perfectly fine.
closes: #14679
Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 06 May 2024 20:00:09 +0200 |
parents | 85d7e01f64b7 |
children | a34e38182b6e |
rev | line source |
---|---|
7 | 1 " Vim filetype plugin file |
30202 | 2 " Language: sh |
3 " Maintainer: Doug Kearns <dougkearns@gmail.com> | |
4 " Previous Maintainer: Dan Sharp | |
33067
5c38f02377d5
runtime(sh): Update ftplugin (#12950)
Christian Brabandt <cb@256bit.org>
parents:
32976
diff
changeset
|
5 " Contributor: Enno Nagel <ennonagel+vim@gmail.com> |
33500
665078e8fea1
runtime(sh): Update ftplugin (#13213)
Christian Brabandt <cb@256bit.org>
parents:
33360
diff
changeset
|
6 " Eisuke Kawashima |
35122
739aaccbca74
runtime(sh,zsh): clear $MANPAGER in ftplugin before shelling out
Christian Brabandt <cb@256bit.org>
parents:
34440
diff
changeset
|
7 " Last Change: 2024 May 06 by Vim Project (MANPAGER=) |
7 | 8 |
30202 | 9 if exists("b:did_ftplugin") |
10 finish | |
11 endif | |
7 | 12 let b:did_ftplugin = 1 |
13 | |
14 let s:save_cpo = &cpo | |
15 set cpo-=C | |
16 | |
34440
85d7e01f64b7
runtime(sh): Update ftplugin, fix #14101 (#14102)
Christian Brabandt <cb@256bit.org>
parents:
34134
diff
changeset
|
17 setlocal comments=b:# |
30202 | 18 setlocal commentstring=#\ %s |
19 setlocal formatoptions-=t formatoptions+=croql | |
20 | |
21 let b:undo_ftplugin = "setl com< cms< fo<" | |
7 | 22 |
23 " Shell: thanks to Johannes Zellner | |
30202 | 24 if exists("loaded_matchit") && !exists("b:match_words") |
25 let b:match_ignorecase = 0 | |
26 let s:sol = '\%(;\s*\|^\s*\)\@<=' " start of line | |
27 let b:match_words = | |
28 \ s:sol .. 'if\>:' .. s:sol.'elif\>:' .. s:sol.'else\>:' .. s:sol .. 'fi\>,' .. | |
29 \ s:sol .. '\%(for\|while\)\>:' .. s:sol .. 'done\>,' .. | |
30 \ s:sol .. 'case\>:' .. s:sol .. 'esac\>' | |
31 unlet s:sol | |
32 let b:undo_ftplugin ..= " | unlet! b:match_ignorecase b:match_words" | |
7 | 33 endif |
34 | |
30202 | 35 if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") |
34134
8ae680be2a51
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents:
33500
diff
changeset
|
36 let b:browsefilter = "Bourne Shell Scripts (*.sh)\t*.sh\n" .. |
8ae680be2a51
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents:
33500
diff
changeset
|
37 \ "Korn Shell Scripts (*.ksh)\t*.ksh\n" .. |
8ae680be2a51
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents:
33500
diff
changeset
|
38 \ "Bash Shell Scripts (*.bash)\t*.bash\n" |
8ae680be2a51
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents:
33500
diff
changeset
|
39 if has("win32") |
8ae680be2a51
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents:
33500
diff
changeset
|
40 let b:browsefilter ..= "All Files (*.*)\t*\n" |
8ae680be2a51
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents:
33500
diff
changeset
|
41 else |
8ae680be2a51
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents:
33500
diff
changeset
|
42 let b:browsefilter ..= "All Files (*)\t*\n" |
8ae680be2a51
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents:
33500
diff
changeset
|
43 endif |
30202 | 44 let b:undo_ftplugin ..= " | unlet! b:browsefilter" |
7 | 45 endif |
46 | |
33500
665078e8fea1
runtime(sh): Update ftplugin (#13213)
Christian Brabandt <cb@256bit.org>
parents:
33360
diff
changeset
|
47 if get(b:, "is_bash", 0) |
33067
5c38f02377d5
runtime(sh): Update ftplugin (#12950)
Christian Brabandt <cb@256bit.org>
parents:
32976
diff
changeset
|
48 if !has("gui_running") && executable("less") |
35122
739aaccbca74
runtime(sh,zsh): clear $MANPAGER in ftplugin before shelling out
Christian Brabandt <cb@256bit.org>
parents:
34440
diff
changeset
|
49 command! -buffer -nargs=1 ShKeywordPrg silent exe '!bash -c "{ help "<args>" 2>/dev/null || MANPAGER= man "<args>"; } | LESS= less"' | redraw! |
33500
665078e8fea1
runtime(sh): Update ftplugin (#13213)
Christian Brabandt <cb@256bit.org>
parents:
33360
diff
changeset
|
50 elseif has("terminal") |
665078e8fea1
runtime(sh): Update ftplugin (#13213)
Christian Brabandt <cb@256bit.org>
parents:
33360
diff
changeset
|
51 command! -buffer -nargs=1 ShKeywordPrg silent exe ':term bash -c "help "<args>" 2>/dev/null || man "<args>""' |
32976
d23645a0aca8
runtime: configure keywordpg for some file types (#5566)
Christian Brabandt <cb@256bit.org>
parents:
30202
diff
changeset
|
52 else |
35122
739aaccbca74
runtime(sh,zsh): clear $MANPAGER in ftplugin before shelling out
Christian Brabandt <cb@256bit.org>
parents:
34440
diff
changeset
|
53 command! -buffer -nargs=1 ShKeywordPrg echo system('bash -c "help <args>" 2>/dev/null || MANPAGER= man "<args>"') |
32976
d23645a0aca8
runtime: configure keywordpg for some file types (#5566)
Christian Brabandt <cb@256bit.org>
parents:
30202
diff
changeset
|
54 endif |
33500
665078e8fea1
runtime(sh): Update ftplugin (#13213)
Christian Brabandt <cb@256bit.org>
parents:
33360
diff
changeset
|
55 setlocal keywordprg=:ShKeywordPrg |
665078e8fea1
runtime(sh): Update ftplugin (#13213)
Christian Brabandt <cb@256bit.org>
parents:
33360
diff
changeset
|
56 let b:undo_ftplugin ..= " | setl kp< | sil! delc -buffer ShKeywordPrg" |
32976
d23645a0aca8
runtime: configure keywordpg for some file types (#5566)
Christian Brabandt <cb@256bit.org>
parents:
30202
diff
changeset
|
57 endif |
d23645a0aca8
runtime: configure keywordpg for some file types (#5566)
Christian Brabandt <cb@256bit.org>
parents:
30202
diff
changeset
|
58 |
7 | 59 let &cpo = s:save_cpo |
3410
94601b379f38
Updated runtime files. Add Dutch translations.
Bram Moolenaar <bram@vim.org>
parents:
2034
diff
changeset
|
60 unlet s:save_cpo |
30202 | 61 |
62 " vim: nowrap sw=2 sts=2 ts=8 noet: |