blob: 11f6104099dcbe52014c7419c928bef2395f77da (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
use std
pkg escfmt =
type escsh = byte[:]
const sh : (s : byte[:] -> escsh)
;;
const __init__ = {
var s = ("" : escsh)
std.fmtinstall(std.typeof(s), shfmt, [][:])
}
const sh = {s
-> (s : escsh)
}
const shfmt = {sb, ap, args
var s : byte[:]
s = std.vanext(ap)
std.sbputb(sb, ('\'' : byte))
for b in s
if b == ('\'' : byte)
std.sbputs(sb, "'\\''")
else
std.sbputb(sb, b)
;;
;;
std.sbputb(sb, ('\'' : byte))
}
|