escapeShellArg
lib.escapeShellArg
Docs pulled from | This Revision | 10 minutes ago
Quote string
to be used safely within the Bourne shell if it has any
special characters.
Inputs
string
- 1. Function argument
Type
escapeShellArg :: string -> string
Examples
lib.strings.escapeShellArg
usage example
escapeShellArg "esc'ape\nme"
=> "'esc'\\''ape\nme'"
Noogle detected
Implementation
The following is the current implementation of this function.
escapeShellArg = arg:
let
string = toString arg;
in
if match "[[:alnum:],._+:@%/-]+" string == null
then "'${replaceStrings ["'"] ["'\\''"] string}'"
else string;