#!/bin/sh
# redo-dot – bourne shell implementation of DJB redo
# Copyright © 2015  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.

# Prints redo dependencies in dot(1) format. Usage is similar to this:
# redo-dot |sed s%"$(pwd)"/%%g >deps.dot; dot deps.dot -Tpng >deps.png

echo 'digraph dependencies { rankdir=LR'
for depfile in $(find .redo -name '*.dependencies'); do
  while read dependency ctime md5sum; do
    file="${depfile%.dependencies}"; file="${file#.redo}"
    printf '"%s" -> "%s"\n' "$file" "$dependency"
  done <"$depfile"
done
echo '}'
