codekingpro/portable-devtools
115k
1# shell_quote --- quote an argument for passing to the shell2#3# This file and how to use it are described in the manual.4# Therefore, we respectfully advise you to Read The Fine Manual5# for more information.6#7# Michael Brennan8# brennan@madronabluff.com9# September 201410 11function shell_quote(s, # parameter12 SINGLE, QSINGLE, i, X, n, ret) # locals13{14 if (s == "")15 return "\"\""16 17 SINGLE = "\x27" # single quote18 QSINGLE = "\"\x27\""19 n = split(s, X, SINGLE)20 21 ret = SINGLE X[1] SINGLE22 for (i = 2; i <= n; i++)23 ret = ret QSINGLE SINGLE X[i] SINGLE24 25 return ret26}27 