guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/03: doc: Fix xref translation macro.


From: guix-commits
Subject: 01/03: doc: Fix xref translation macro.
Date: Mon, 26 Oct 2020 19:40:46 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit aa7edc9449a7cf796892f5a0369295a95ddbbcf8
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Mon Oct 26 23:19:26 2020 +0100

    doc: Fix xref translation macro.
    
    * doc/local.mk (xref_command): Wrap loop body in 'if [ -n "$$e" ]'.
    This avoids shell syntax errors when producing
    doc/guix-cookbook.de.texi, which for some reason gets an empty 'e' at
    one point.  Quote the first argument to 'head'.
---
 doc/local.mk | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/doc/local.mk b/doc/local.mk
index aca1958..97122c7 100644
--- a/doc/local.mk
+++ b/doc/local.mk
@@ -96,14 +96,16 @@ define xref_command
 cat "$@.tmp" | egrep '@p?x?ref' -A1 | sed 'N;s|--\n||g;P;D' | sed 's|^| |g' | \
         tr -d '\012' | sed 's|\(@p\?x\?ref\)|\n\1|g' | egrep '@p?x?ref' | \
         sed 's|^.*@p\?x\?ref{\([^,}]*\).*$$|\1|g' | sort | uniq | while read 
e; do \
-  line=$$(grep -n "^msgid \"$$e\"" "$<" | cut -f1 --delimiter=":") ;\
-  ((line++)) ;\
-  if [ "$$line" != "1" ]; then \
-    translation=$$(head -n $$line "$<" | tail -1 | grep msgstr | sed 's|msgstr 
"\(.*\)"|\1|') ;\
-    if [ "$$translation" != "" ]; then \
-         sed "N;s@\(p\?x\?ref\){$$(echo $$e | sed 's| |[\\n 
]|g')\(,\|}\)@\1{$$translation\2@g;P;D" -i "$@.tmp" ;\
-    fi ;\
-  fi ;\
+    if [ -n "$$e" ]; then \
+      line=$$(grep -n "^msgid \"$$e\"" "$<" | cut -f1 --delimiter=":") ;\
+      ((line++)) ;\
+      if [ "$$line" != "1" ]; then \
+       translation=$$(head -n "$$line" "$<" | tail -1 | grep msgstr | sed 
's|msgstr "\(.*\)"|\1|') ;\
+       if [ "$$translation" != "" ]; then \
+             sed "N;s@\(p\?x\?ref\){$$(echo $$e | sed 's| |[\\n 
]|g')\(,\|}\)@\1{$$translation\2@g;P;D" -i "$@.tmp" ;\
+       fi ;\
+      fi ;\
+   fi ;\
 done
 endef
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]