#!/bin/sh # redo-dot – bourne shell implementation of DJB redo # Copyright © 2018 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 [ -d .redo ] || exit 1 pattern=${1:-*} match() case "${1}" in ${pattern}) : ;; *) ! : ;; esac _escape() { printf '%s' "$1" | sed 's/\\/\\\\/g;s/\"/\\\"/g' } IFS=' ' cat < "%s"\n' "$(_escape "${file}")" "$(_escape "${dependency}")" ;; esac done <"$depfile" done printf '}\nsubgraph dependencies_ne { edge[style=dotted,minlen=1]\n' for depfile in $(find .redo -name '*.dependencies_ne'); do while read -r dependency_ne; do file="${depfile%.dependencies_ne}"; file="${file#.redo}"; match "${file}" || match "${dependency_ne}" || continue printf '"%s" -> "%s"\n' "$(_escape "${file}")" "$(_escape "${dependency_ne}")" done <"$depfile" done printf '}\n' for stampfile in $(find .redo -name '*.stamp'); do file="${stampfile%.stamp}"; file="${file#.redo}" match "${file}" || continue printf '"%s" [style=dashed]\n' "$(_escape "${file}")" done printf '}\n'