[pushed] wwwdocs: preprocess: Check whether input files exist

Message ID 20230519140206.1369B33E6E@hamza.pair.com
State Unresolved
Headers
Series [pushed] wwwdocs: preprocess: Check whether input files exist |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Gerald Pfeifer May 19, 2023, 2:01 p.m. UTC
  This has not come up in all those years since the preprocess script
usually is invoked from other scripts, notably post commit hooks. It
can, however, be invoked manually, and error handling is generally a
good thing.

Instead of
   cat: foo/bar/index.html: No such file or directory
   New file /www/gcc/htdocs/foo/bar/index.html
and an empty output file, we now get
   Input file foo/bar/index.html not found.
when invoking `preprocess foo/bar/index.html`.

Pushed.
Gerald
---
 bin/preprocess | 5 +++++
 1 file changed, 5 insertions(+)
  

Patch

diff --git a/bin/preprocess b/bin/preprocess
index c62ba457..c6d34c4b 100755
--- a/bin/preprocess
+++ b/bin/preprocess
@@ -155,6 +155,11 @@  process_file()
     # Strip possibly leading "./".
     f=`echo $1 | sed -e 's#^\./##'`
 
+    if [ ! -f "$SOURCETREE/$f" ] wwwdocs:; then
+        echo "Input file $f not found."
+        return
+    fi
+
     if [ ! -d "$DESTTREE/`dirname $f`" ] wwwdocs:; then
         echo "Creating new directory `dirname $f`."
         mkdir -p $DESTTREE/`dirname $f`