From 60a495f02e7dec1db1776d8344cdd4da6a52a41f Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 3 Oct 2006 12:44:42 +0000 Subject: updated for version 7.0-111 --- runtime/autoload/gzip.vim | 22 +++++++++++++++------- runtime/doc/eval.txt | 19 ++++++++++++++++++- 2 files changed, 33 insertions(+), 8 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/gzip.vim b/runtime/autoload/gzip.vim index 1e119a455..933d83d09 100644 --- a/runtime/autoload/gzip.vim +++ b/runtime/autoload/gzip.vim @@ -1,6 +1,6 @@ " Vim autoload file for editing compressed files. " Maintainer: Bram Moolenaar -" Last Change: 2006 Jul 19 +" Last Change: 2006 Oct 03 " These functions are used by the gzip plugin. @@ -68,9 +68,9 @@ fun gzip#read(cmd) let tmp = tempname() let tmpe = tmp . "." . expand(":e") " write the just read lines to a temp file "'[,']w tmp.gz" - execute "silent '[,']w " . tmpe + execute "silent '[,']w " . escape(tmpe, ' ') " uncompress the temp file: call system("gzip -dn tmp.gz") - call system(a:cmd . " " . tmpe) + call system(a:cmd . " " . s:escape(tmpe)) if !filereadable(tmp) " uncompress didn't work! Keep the compressed file then. echoerr "Error: Could not read uncompressed file" @@ -127,9 +127,9 @@ fun gzip#write(cmd) let nmt = s:tempname(nm) if rename(nm, nmt) == 0 if exists("b:gzip_comp_arg") - call system(a:cmd . " " . b:gzip_comp_arg . " '" . nmt . "'") + call system(a:cmd . " " . b:gzip_comp_arg . " " . s:escape(nmt)) else - call system(a:cmd . " '" . nmt . "'") + call system(a:cmd . " " . s:escape(nmt)) endif call rename(nmt . "." . expand(":e"), nm) endif @@ -154,10 +154,10 @@ fun gzip#appre(cmd) if rename(nm, nmte) == 0 if &patchmode != "" && getfsize(nm . &patchmode) == -1 " Create patchmode file by creating the decompressed file new - call system(a:cmd . " -c " . nmte . " > " . nmt) + call system(a:cmd . " -c " . s:escape(nmte) . " > " . s:escape(nmt)) call rename(nmte, nm . &patchmode) else - call system(a:cmd . " " . nmte) + call system(a:cmd . " " . s:escape(nmte)) endif call rename(nmt, nm) endif @@ -175,4 +175,12 @@ fun s:tempname(name) return fnamemodify(a:name, ":p:h") . "/X~=@l9q5" endfun +fun s:escape(name) + " shellescape() was added by patch 7.0.111 + if v:version > 700 || (v:version == 700 && has('patch111')) + return shellescape(a:name) + endif + return "'" . a:name . "'" +endfun + " vim: set sw=2 : diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 939e7849b..caafd75ac 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 7.0. Last change: 2006 May 06 +*eval.txt* For Vim version 7.0. Last change: 2006 Sep 22 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1709,6 +1709,8 @@ setreg( {n}, {v}[, {opt}]) Number set register to value and type settabwinvar( {tabnr}, {winnr}, {varname}, {val}) set {varname} in window {winnr} in tab page {tabnr} to {val} setwinvar( {nr}, {varname}, {val}) set {varname} in window {nr} to {val} +shellescape( {string}) String escape {string} for use as shell + command argument simplify( {filename}) String simplify filename as much as possible sort( {list} [, {func}]) List sort {list}, using {func} to compare soundfold( {word}) String sound-fold {word} @@ -4434,6 +4436,21 @@ setwinvar({nr}, {varname}, {val}) *setwinvar()* :call setwinvar(1, "&list", 0) :call setwinvar(2, "myvar", "foobar") +shellescape({string}) *shellescape()* + Escape {string} for use as shell command argument. + On MS-Windows and MS-DOS, when 'shellslash' is not set, it + will enclose {string} double quotes and double all double + quotes within {string}. + For other systems, it will enclose {string} in single quotes + and replace all "'" with "'\''". + Example: > + :echo shellescape('c:\program files\vim') +< results in: + "c:\program files\vim" ~ + Example usage: > + :call system("chmod +x -- " . shellescape(expand("%"))) + + simplify({filename}) *simplify()* Simplify the file name as much as possible without changing the meaning. Shortcuts (on MS-Windows) or symbolic links (on -- cgit v1.2.1