@@ -35,17 +35,18 @@ set cpo&vim
3535" Commands Launch/URL {{{2
3636" surpress output of command; use bang for GUI applications
3737
38- " set up redirection (avoids browser messages)
39- " by default if not set, g:netrw_suppress_gx_mesg is true
40- if get (g: , ' netrw_suppress_gx_mesg' , 1 )
41- if &srr = ~# " %s"
42- let s: redir = printf (&srr , has (" win32" ) ? " nul" : " /dev/null" )
43- else
44- let s: redir= &srr .. (has (" win32" ) ? " nul" : " /dev/null" )
38+ func s: redir ()
39+ " set up redirection (avoids browser messages)
40+ " by default if not set, g:netrw_suppress_gx_mesg is true
41+ if get (g: , ' netrw_suppress_gx_mesg' , 1 )
42+ if &srr = ~# " %s"
43+ return printf (&srr , has (" win32" ) ? " nul" : " /dev/null" )
44+ else
45+ return &srr .. (has (" win32" ) ? " nul" : " /dev/null" )
46+ endif
4547 endif
46- else
47- let s: redir= " "
48- endif
48+ return ' '
49+ endfunc
4950
5051if has (' unix' )
5152 if has (' win32unix' )
@@ -60,26 +61,26 @@ if has('unix')
6061 " Adding "" //b` sets void title, hides cmd window and blocks path conversion
6162 " of /b to \b\ " by MSYS2; see https://www.msys2.org/docs/filesystem-paths/
6263 command -complete =shellcmd -nargs =1 - bang Launch
63- \ exe ' silent !start "" //b' trim (<q-args> ) s: redir | redraw !
64+ \ exe ' silent !start "" //b' trim (<q-args> ) s: redir() | redraw !
6465 else
6566 " imitate /usr/bin/start script for other environments and hope for the best
6667 command -complete =shellcmd -nargs =1 - bang Launch
67- \ exe ' silent !cmd //c start "" //b' trim (<q-args> ) s: redir | redraw !
68+ \ exe ' silent !cmd //c start "" //b' trim (<q-args> ) s: redir() | redraw !
6869 endif
6970 elseif exists (' $WSL_DISTRO_NAME' ) " use cmd.exe to start GUI apps in WSL
7071 command -complete =shellcmd -nargs =1 - bang Launch execute ' :silent !' ..
7172 \ ((<q-args> = ~? ' \v<\f+\.(exe|com|bat|cmd)>' ) ?
7273 \ ' cmd.exe /c start "" /b' trim (<q-args> ) :
73- \ ' nohup ' trim (<q-args> ) s: redir ' &' )
74+ \ ' nohup ' trim (<q-args> ) s: redir() ' &' )
7475 \ | redraw !
7576 else
7677 command -complete =shellcmd -nargs =1 - bang Launch
77- \ exe ' :silent ! nohup' trim (<q-args> ) s: redir ' &' | redraw !
78+ \ exe ' :silent ! nohup' trim (<q-args> ) s: redir() ' &' | redraw !
7879 endif
7980elseif has (' win32' )
8081 command -complete =shellcmd -nargs =1 - bang Launch
8182 \ exe ' silent !' .. (&shell = ~? ' \<cmd\.exe\>' ? ' ' : ' cmd.exe /c' )
82- \ ' start /b ' trim (<q-args> ) s: redir | redraw !
83+ \ ' start /b ' trim (<q-args> ) s: redir() | redraw !
8384endif
8485if exists (' :Launch' ) == 2
8586 " Git Bash
@@ -95,17 +96,15 @@ if exists(':Launch') == 2
9596 " MacOS
9697 elseif executable (' open' )
9798 let s: cmd = ' open'
98- else
99- let s: cmd = ' '
10099 endif
101- function s: Open (cmd, file )
102- if empty ( a : cmd ) && ! exists (' g:netrw_browsex_viewer' )
100+ function s: Open (file )
101+ if ! exists ( ' s :cmd' ) && ! exists (' g:netrw_browsex_viewer' )
103102 echoerr " No program to open this path found. See :help Open for more information."
104103 else
105- Launch cmd shellescape (a: file , 1 )
104+ exe ' Launch' s: cmd shellescape (a: file , 1 )
106105 endif
107106 endfunction
108- command -complete =file -nargs =1 Open call s: Open (s: cmd , <q-args> )
107+ command -complete =file -nargs =1 Open call s: Open (<q-args> )
109108endif
110109
111110if ! exists (' g:netrw_regex_url' )
0 commit comments