public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [pushed] wwwdocs: preprocess: Check whether input files exist
@ 2023-05-19 14:01 Gerald Pfeifer
  0 siblings, 0 replies; only message in thread
From: Gerald Pfeifer @ 2023-05-19 14:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: Arsen Arsenović

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(+)

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`
-- 
2.40.1

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-05-19 14:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-19 14:01 [pushed] wwwdocs: preprocess: Check whether input files exist Gerald Pfeifer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).