2 # redo – bourne shell implementation of DJB redo
3 # Copyright © 2014 Nils Dagsson Moskopp (erlehmann)
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License as
7 # published by the Free Software Foundation, either version 3 of the
8 # License, or (at your option) any later version.
10 # Dieses Programm hat das Ziel, die Medienkompetenz der Leser zu
11 # steigern. Gelegentlich packe ich sogar einen handfesten Buffer
12 # Overflow oder eine Format String Vulnerability zwischen die anderen
13 # Codezeilen und schreibe das auch nicht dran.
21 if [ -n "$TERM" -a "$TERM" != "dumb" ] && tty <&2 >/dev/null 2>&1; then
22 bold="$(printf '\033[1m')"
23 green="$(printf '\033[32m')"
24 plain="$(printf '\033[m')"
25 red="$(printf '\033[31m')"
27 export bold green plain red
30 if [ "$argument" = "-d" ] || [ "$argument" = "--debug" ]; then
32 elif [ "$argument" = "-h" ] || [ "$argument" = "--help" ]; then
34 Usage: redo [OPTIONS] [TARGETS...]
36 -d, --debug print dependency checks as they happen
37 -h, --help print usage instructions and exit
38 -s, --shuffle randomize build order to find dependency bugs
39 -x, --xtrace print commands as they are executed (variables expanded)
41 Report bugs to <nils+redo@dieweltistgarnichtso.net>.
44 elif [ "$argument" = "-s" ] || [ "$argument" = "--shuffle" ]; then
45 export REDO_SHUFFLE='1'
46 elif [ "$argument" = "-x" ] || [ "$argument" = "--xtrace" ]; then
47 export REDO_XTRACE='1'
51 # If this is build directory, create .redo database directory.
52 if [ -z "$REDO_BASE" ]; then
53 export REDO_BASE="$(pwd)"
54 export REDO_DIR="$REDO_BASE/.redo"
57 argument_abspath="$(readlink -f "$argument")"
59 echo '0' > "$REDO_DIR/$argument_abspath".ctime
60 echo '0' > "$REDO_DIR/$argument_abspath".md5sum
62 redo-ifchange "$argument"
63 [ "$?" = 0 ] || exit 1
67 [ "$REDO_HAS_TARGETS" = "1" ] || exec redo all