diff --git a/src/filters/rcldoc b/src/filters/rcldoc index 287188c8..0b132fa7 100755 --- a/src/filters/rcldoc +++ b/src/filters/rcldoc @@ -90,23 +90,30 @@ umask 77 checkcmds awk antiword iconv -# output the result +# We need to do some strange stuff to retrieve the status from antiword. Things +# would be simpler if we relied on using bash. +# Explanations: +#http://stackoverflow.com/questions/1221833/bash-pipe-output-and-capture-exit-status + +stdintoexitstatus() { + read exitstatus + return $exitstatus +} + # The strange 'BEGIN' setup is to prevent 'file' from thinking this file # is an awk program -$decoder "$infile" | +(((($decoder "$infile"; echo $? >&3) | awk 'BEGIN'\ ' { cont = "" gotdata = 0 } { - if (!($0 ~ /^[ ]*$/)) { + if (!($0 ~ /^[ ]*$/) && gotdata == 0) { + print "
" gotdata = 1 - if (gotdata == 0) { - print "
" - } } $0 = cont $0 cont = "" @@ -124,17 +131,19 @@ awk 'BEGIN'\ print "
"
next
}
- gsub(/&/, "\\&", $0)
- gsub(/, "\\<", $0)
- gsub(/>/, "\\>", $0)
- print $0 "
"
+ if (gotdata == 1) {
+ gsub(/&/, "\\&", $0)
+ gsub(/, "\\<", $0)
+ gsub(/>/, "\\>", $0)
+
+ print $0 "
"
+ }
}
END {
- if (gotdata == 0)
- exit(1)
- print "