From 864cc0373fd6095295f68cc44d1657bd17269732 Mon Sep 17 00:00:00 2001 From: kitsunyan Date: Thu, 15 Mar 2018 03:05:14 +0300 Subject: Provide custom config for makepkg instead of exporting variables --- src/utils.nim | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/utils.nim') diff --git a/src/utils.nim b/src/utils.nim index 1d7c6bd..8316110 100644 --- a/src/utils.nim +++ b/src/utils.nim @@ -179,6 +179,20 @@ proc removeDirQuiet*(s: string) = except: discard +const bashSpecialCharacters = " \t\"'`()[]{}#&|;!\\*~<>?" + +proc bashEscape*(s: string): string = + result = "" + for c in s: + if c in bashSpecialCharacters: + result &= "\\" & c + elif c == "\n"[0]: + result &= "$'\\n'" + elif c.cuint < 0x20.cuint or c.cuint > 0x80.cuint: + result &= "$'\\0x" & c.toHex & "'" + else: + result &= c + proc dgettext(domain: cstring, s: cstring): cstring {.cdecl, importc: "dgettext".} -- cgit v1.2.3-70-g09d2