aboutsummaryrefslogtreecommitdiff
path: root/src/utils.nim
diff options
context:
space:
mode:
authorkitsunyan2018-03-15 00:05:14 +0000
committerkitsunyan2018-03-15 00:05:14 +0000
commit864cc0373fd6095295f68cc44d1657bd17269732 (patch)
tree5b6f8a6002fc6874eb9fe292f3afad45b837a8ea /src/utils.nim
parentc09885fbad8d73506982d128c12603fdc82ec5ee (diff)
Provide custom config for makepkg instead of exporting variables
Diffstat (limited to 'src/utils.nim')
-rw-r--r--src/utils.nim14
1 files changed, 14 insertions, 0 deletions
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".}