about summary refs log tree commit diff
path: root/bin/redo-ifcreate
diff options
context:
space:
mode:
authorPatryk Niedźwiedziński <pniedzwiedzinski19@gmail.com>2021-06-15 23:30:05 +0200
committerPatryk Niedźwiedziński <pniedzwiedzinski19@gmail.com>2021-06-15 23:30:05 +0200
commitd831434e95c6a3b33a8af04e630d34f078d26e4f (patch)
tree93965830662798a4c8674634110eac88bdb3a6ab /bin/redo-ifcreate
downloadspiewnik-d831434e95c6a3b33a8af04e630d34f078d26e4f.tar.gz
spiewnik-d831434e95c6a3b33a8af04e630d34f078d26e4f.zip
Init
Diffstat (limited to 'bin/redo-ifcreate')
-rwxr-xr-xbin/redo-ifcreate35
1 files changed, 35 insertions, 0 deletions
diff --git a/bin/redo-ifcreate b/bin/redo-ifcreate
new file mode 100755
index 0000000..5365044
--- /dev/null
+++ b/bin/redo-ifcreate
@@ -0,0 +1,35 @@
+#!/bin/sh -eu
+# redo-ifcreate – bourne shell implementation of DJB redo
+# Copyright © 2014-2019  Nils Dagsson Moskopp (erlehmann)
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+
+# Dieses Programm hat das Ziel, die Medienkompetenz der Leser zu
+# steigern. Gelegentlich packe ich sogar einen handfesten Buffer
+# Overflow oder eine Format String Vulnerability zwischen die anderen
+# Codezeilen und schreibe das auch nicht dran.
+
+# redo-ifcreate takes a list of non-existent files (sources) and adds
+# them as non-existence dependencies to the current target (the one
+# calling redo-ifcreate). If a non-existence dependency of a target
+# exists, the target will be rebuilt.
+
+for filename; do
+ # BusyBox v.1.19.3 outputs nothing for “readlink -f” on a nonexistent
+ # file, which means that redo-ifcreate can not canonicalize filenames.
+ case "${filename}" in
+  /*) dependency_ne="${filename}" ;;
+  *) dependency_ne="${PWD%/}/${filename}" ;;
+ esac
+ if [ ! -e "${dependency_ne}" ]; then
+  mkdir -p $(LANG=C dirname "${REDO_DIR}/${REDO_TARGET}".dependencies_ne.tmp)
+  printf '%s\n' "${dependency_ne}" >> "${REDO_DIR}/${REDO_TARGET}".dependencies_ne.tmp
+ else
+  printf "%sredo-ifcreate: %s exists.%s\n" "${REDO_COLOR_FAILURE}" "$dependency_ne" "${REDO_PLAIN}" >&2
+  exit 1
+  fi
+done
+exit 0