[ ... ] > This kind of glob depends on your 'shell' option, try 'csh' instead > whose glob command is better than the 'echo' of POSIX sh. > > Or maybe you are interested in the patch I post to dev sometime ago.
I see now. The final goal is function which would tell me what files are
in given directory. That's why I started to use glob. To be as correct
as possible I started to write my wrapper function. So far it is:
Unfortunately, it does not catch hidden files on windows :(
fu! Glob(pattern)
try
if !has('unix')
" Windows ... Can anything else fall here which is not
apropriate ?
let l:res=glob(a:pattern)
break
if match(&shell, '\(^\|/\)t\?csh$') >= 0
" We do have (t)csh
let l:res=glob(a:pattern)
break
endif
if executable('csh') > 0 || executable('tcsh') > 0
" We can reach (t)csh, so use it for a while
let l:newsh='csh'
if ( executable('csh') == 0 )
let l:newsh='tcsh'
endif
let l:sh=&shell
try
exe "set shell=".l:newsh
let l:res=glob(a:pattern)
finally
" Don't clobber the &shell variable
exe "set shell=".l:sh
endtry
break
endif
if match(&shell, '\(^\|/\)bash$') >= 0
" Bash way of getting all the files (works for bash 2
newer)
let l:pat=substitute(a:pattern,
'\([^[:alnum:]\*\?/_-]\)', '\\\1', "g")
let l:res=system("shopt -s nullglob; for a in
".l:pat."; do echo \"$a\"; done")
break
endif
if executable('python')
" Python is common these days (Perl default glob
implementation sucks)
let l:res=system ('python', "import glob\nfor i in
glob.glob('".escape(a:pattern,"'\\")."'):\n print i")
break
endif
" Fallback to default
let l:res=glob(a:pattern)
endtry
return split (l:res, "\n")
endf
I tested it on linux, solaris 8, solaris 10 and windows.
Thank you for your input
--
Vlad
pgpikNQxZVoCp.pgp
Description: PGP signature
