summaryrefslogtreecommitdiff
path: root/lang/modula-3-lib/scripts/check_files
diff options
context:
space:
mode:
Diffstat (limited to 'lang/modula-3-lib/scripts/check_files')
-rw-r--r--lang/modula-3-lib/scripts/check_files29
1 files changed, 29 insertions, 0 deletions
diff --git a/lang/modula-3-lib/scripts/check_files b/lang/modula-3-lib/scripts/check_files
new file mode 100644
index 000000000000..2c120f417479
--- /dev/null
+++ b/lang/modula-3-lib/scripts/check_files
@@ -0,0 +1,29 @@
+#! /bin/sh
+#
+# check_files listfile m3dir sysdir
+#
+# The listfile must contain a list of filenames, one per line. It is read,
+# and all leading instances of m3dir are replaced with sysdir. If all
+# the resulting files exist and are readable, then sysdir is echoed to
+# the standard output. Otherwise, nothing is echoed. In any event, the
+# exit status is successful.
+
+if [ $# -ne 3 ]; then
+ echo "Usage: $0 listfile m3dir sysdir" >&2
+ exit 1
+fi
+
+listfile=$1
+m3dir=$2
+sysdir=$3
+
+result=${sysdir}
+for i in $(sed "s,^${m3dir},${sysdir}," ${listfile}); do
+ if [ ! -r $i ]; then
+ result=
+ break
+ fi
+done
+
+echo ${result}
+exit 0