Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ddu_vim/deps.ts>fn.shellescape

Dark deno-powered UI framework for neovim/Vim8
Go to Latest
function fn.shellescape
import { fn } from "https://deno.land/x/ddu_vim@v1.13.0/deps.ts";
const { shellescape } = fn;

Escape {string} for use as a shell command argument. When the 'shell' contains powershell (MS-Windows) or pwsh (MS-Windows, Linux, and MacOS) then it will enclose {string} in single quotes and will double up all internal single quotes. On MS-Windows, when 'shellslash' is not set, it will enclose {string} in double quotes and double all double quotes within {string}. Otherwise it will enclose {string} in single quotes and replace all "'" with "'''". When the {special} argument is present and it's a non-zero Number or a non-empty String (|non-zero-arg|), then special items such as "!", "%", "#" and "" will be preceded by a backslash. This backslash will be removed again by the |:!| command. The "!" character will be escaped (again with a |non-zero-arg| {special}) when 'shell' contains "csh" in the tail. That is because for csh and tcsh "!" is used for history replacement even when inside single quotes. With a |non-zero-arg| {special} the character is also escaped. When 'shell' containing "csh" in the tail it's escaped a second time. The "" character will be escaped when 'shell' contains "fish" in the tail. That is because for fish "" is used as an escape character inside single quotes. Example of use with a |:!| command: :exe '!dir ' . shellescape(expand(''), 1) This results in a directory listing for the file under the cursor. Example of use with |system()|: :call system("chmod +w -- " . shellescape(expand("%"))) See also |::S|. Can also be used as a |method|: GetCommand()->shellescape()

Parameters

denops: Denops
string: unknown
optional
special: unknown

Returns

Promise<unknown>