link shquote
December 30, 1993; Robert J. Alexander
This file is in the public domain.
The following procedures are useful for writing Icon programs that generate shell commands. Certain characters cannot appear in the open in strings that are to be interpreted as "words" by command shells. This family of procedures assists in quoting such strings so that they will be interpreted as single words. Quoting characters are applied only if necessary -- if strings need no quoting they are returned unchanged. shquote(s1, s2, ..., sN) : s -- Produces a string of words s1, s2, ..., sN that are properly separated and quoted for the Bourne Shell (sh). cshquote(s1, s2, ..., sN) : s -- Produces a string of words s1, s2, ..., sN that are properly separated and quoted for the C-Shell (csh). mpwquote(s1, s2, ..., sN) : s -- Produces a string of words s1, s2, ..., sN that are properly separated and quoted for the Macintosh Programmer's Workshop shell (MPW Shell). dequote(s1,s2) : s3 -- Produces the UNIX-style command line word s1 with any quoting characters removed. s2 is the escape character required by the shell (s2 defaults the the usual UNIX escape character, the backslash "\\").