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 -x, --xtrace print commands as they are executed (variables expanded)
40 Report bugs to <nils+redo@dieweltistgarnichtso.net>.
43 elif [ "$argument" = "-s" ] || [ "$argument" = "--shuffle" ]; then
44 export REDO_SHUFFLE='1'
45 elif [ "$argument" = "-x" ] || [ "$argument" = "--xtrace" ]; then
46 export REDO_XTRACE='1'
50 # If this is build directory, create .redo database directory.
51 if [ -z "$REDO_BASE" ]; then
52 export REDO_BASE="$(pwd)"
53 export REDO_DIR="$REDO_BASE/.redo"
56 argument_abspath="$(readlink -f "$argument")"
58 echo '0' > "$REDO_DIR/$argument_abspath".ctime
59 echo '0' > "$REDO_DIR/$argument_abspath".md5sum
61 redo-ifchange "$argument"
62 [ "$?" = 0 ] || exit 1
66 [ "$REDO_HAS_TARGETS" = "1" ] || exec redo all