[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[6266] double backslashes in $0 before passing to (g)awk
From: |
karl |
Subject: |
[6266] double backslashes in $0 before passing to (g)awk |
Date: |
Thu, 14 May 2015 17:28:46 +0000 |
Revision: 6266
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6266
Author: karl
Date: 2015-05-14 17:28:43 +0000 (Thu, 14 May 2015)
Log Message:
-----------
double backslashes in $0 before passing to (g)awk
Modified Paths:
--------------
trunk/ChangeLog
trunk/texindex/texindex.in
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2015-05-13 00:34:02 UTC (rev 6265)
+++ trunk/ChangeLog 2015-05-14 17:28:43 UTC (rev 6266)
@@ -1,3 +1,9 @@
+2015-05-14 Karl Berry <address@hidden>
+
+ * texindex/texindex.in (escaped0): double backslashes in $0
+ for passing to awk.
+ Report from Eli on texinfo-devel, 09 May 2015 14:04:37.
+
2015-05-11 Gavin Smith <address@hidden>
Pretest 5.9.92.
Modified: trunk/texindex/texindex.in
===================================================================
--- trunk/texindex/texindex.in 2015-05-13 00:34:02 UTC (rev 6265)
+++ trunk/texindex/texindex.in 2015-05-14 17:28:43 UTC (rev 6266)
@@ -97,4 +97,21 @@
exit 1
fi
-exec $awk_binary -v Invocation_name="$0" -f "$ti_script" -- "$@"
+# Suppose a symlink named a\tb (four chars) is made to this script, and
+# "a\tb" --help
+# is invoked. We want the output to report the program name as the
+# four chars a, \, t, b, not a, tab, b.
+#
+# But we pass the value using (g)awk -v, and (g)awk processes arguments
+# to -v for escape sequences, so that by the time the rest of the script
+# sees it, it has a tab in it.
+#
+# Conclusion: we must double any backslashes before invoking gawk,
+# by running the command: sed 's,\\,\\\\,g'
+#
+# Sadly, since we have to do this in a shell, we need twice
+# as many backslash characters in the input. Hope it's portable across
+# shells and seds.
+#
+escaped0=`echo "$0" | sed 's,\\\\,\\\\\\\\,g'`
+exec $awk_binary -v Invocation_name="$escaped0" -f "$ti_script" -- "$@"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [6266] double backslashes in $0 before passing to (g)awk,
karl <=