This function ensures that strings you use as arguments to the system() function (or "cmd"|getline commands) are safely quoted. First, all single quotes are converted to '\'', and finally, the argument is wrapped in single quotes.
function shellquote(str) {
gsub(/'/, "'\\''", str)
return sprintf("'%s'", str)
}
Powered by sdf Creative Commons License <pierre.gaston+awk@gmail.com>
Awk Wiki by #awk is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.