From f4fc1ad9bbd765a84dd6033e03541ffde9c7c045 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 13 Jan 2010 06:03:07 -0700 Subject: [PATCH] Document here-doc pitfall. * doc/autoconf.texi (Here-Documents): Mention problem with <<- operator. Reported by Jim Meyering. Signed-off-by: Eric Blake --- ChangeLog | 7 +++++++ doc/autoconf.texi | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6b6fd808..3fa0c5d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-01-13 Eric Blake + + Document here-doc pitfall. + * doc/autoconf.texi (Here-Documents): Mention problem with <<- + operator. + Reported by Jim Meyering. + 2010-01-12 Eric Blake Typo fix in earlier commit. diff --git a/doc/autoconf.texi b/doc/autoconf.texi index ce6ac88f..31550fd5 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -14691,6 +14691,22 @@ macro when it was expanded before in a conditional path, and the condition turned out to be false at runtime, and we end up not executing the macro at all. +Be careful with the use of @samp{<<-} to unindent here-documents. The +behavior is only portable for stripping leading @key{TAB}s, and things +can silently break if an overzealous editor converts to using leading +spaces (not all shells are nice enough to warn about unterminated +here-documents). + +@example +$ @kbd{printf 'cat <<-x\n\t1\n\t 2\n\tx\n' | bash && echo oops} +1 + 2 +$ @kbd{printf 'cat <<-x\n 1\n 2\n x\n' | bash-3.2 && echo oops} + 1 + 2 + x +@end example + @node File Descriptors @section File Descriptors @cindex Descriptors -- 2.11.4.GIT