From: grr Date: Mon, 5 May 1997 11:56:33 +0000 (+0000) Subject: make list2sh.awk safe for meta-characters in SPECIAL X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=19028a92a9d2fc10f39b315a84d7f6517227ab89;p=openbsd make list2sh.awk safe for meta-characters in SPECIAL --- diff --git a/distrib/miniroot/list2sh.awk b/distrib/miniroot/list2sh.awk index f9564e27c23..9245163b10f 100644 --- a/distrib/miniroot/list2sh.awk +++ b/distrib/miniroot/list2sh.awk @@ -1,4 +1,4 @@ -# $OpenBSD: list2sh.awk,v 1.3 1997/04/30 18:52:47 niklas Exp $ +# $OpenBSD: list2sh.awk,v 1.4 1997/05/05 11:56:33 grr Exp $ # $NetBSD: list2sh.awk,v 1.2 1996/05/04 15:45:31 pk Exp $ BEGIN { @@ -51,11 +51,16 @@ $1 == "COPYDIR" { next; } $1 == "SPECIAL" { - printf("echo '%s'\n", $0); - printf("(cd ${TARGDIR};"); - for (i = 2; i <= NF; i++) - printf(" %s", $i); - printf(")\n"); +# escaping shell quotation is ugly whether you use " or ', use cat <<'!' ... + work=$0; + gsub("[\\\\]", "\\\\", work); + gsub("[\"]", "\\\"", work); + gsub("[$]", "\\$", work); + gsub("[`]", "\\&", work); + printf("echo \"%s\"\n", work); + work=$0; + sub("^[ ]*" $1 "[ ]*", "", work); + printf("(cd ${TARGDIR}; %s)\n", work); next; } {