Import updates to some utilities that were sitting in my personal bin
authorMatt McCutchen <matt@mattmccutchen.net>
Thu, 17 Sep 2020 02:06:31 +0000 (22:06 -0400)
committerMatt McCutchen <matt@mattmccutchen.net>
Thu, 17 Sep 2020 02:31:38 +0000 (22:31 -0400)
dir but I never remembered to propagate to my web site.

Modification times:

2006-12-27 10:25:05 -0500 cp2
2009-10-02 07:55:48 -0400 ftx
2012-10-31 01:03:20 -0400 gitar
2010-12-17 23:32:42 -0500 retex
2010-05-16 03:58:43 -0400 stat2
2012-10-31 01:03:02 -0400 ungitar

cp2
ftx
gitar
retex
stat2
ungitar

diff --git a/cp2 b/cp2
index 063a10a..8d42855 100755 (executable)
--- a/cp2
+++ b/cp2
@@ -1,2 +1,2 @@
 #!/bin/bash
-rsync -rltE --chmod=ugo=rwX "$@"
+exec rsync -rltE --chmod=ugo=rwX "$@"
diff --git a/ftx b/ftx
index 7442776..c7772c9 100755 (executable)
--- a/ftx
+++ b/ftx
@@ -18,7 +18,7 @@ function ftx_sub {
                read length
                head -c "$length" >"$1"
                if [ $type == x ]; then
-                       setexec + "$1"
+                       chexec + "$1"
                fi
                skip 1 # newline
                ;;
diff --git a/gitar b/gitar
index 315bf2d..946856e 100755 (executable)
--- a/gitar
+++ b/gitar
@@ -17,25 +17,25 @@ if ! find . -type d -empty | cmp /dev/null - >/dev/null; then
 fi
 
 # Make repository.
-git-init-db >/dev/null
+git init-db >/dev/null
 
 # Make a dummy commit to hold all the files.
 function list-files-to-add {
        find . -wholename './.git' -prune -or '(' -type f -or -type l ')' -printf '%P\n'
 }
-list-files-to-add | git-update-index --add --stdin >/dev/null
-tree=$(git-write-tree)
+list-files-to-add | git update-index --add --stdin >/dev/null
+tree=$(git write-tree)
 function clean-commit {
-       GIT_AUTHOR_NAME='reproducible' GIT_AUTHOR_EMAIL='' GIT_AUTHOR_DATE='946684801 +0000' GIT_COMMITTER_NAME='reproducible' GIT_COMMITTER_EMAIL='' GIT_COMMITTER_DATE='946684801 +0000' git-commit-tree "$@" </dev/null
+       GIT_AUTHOR_NAME='reproducible' GIT_AUTHOR_EMAIL='' GIT_AUTHOR_DATE='946684801 +0000' GIT_COMMITTER_NAME='reproducible' GIT_COMMITTER_EMAIL='' GIT_COMMITTER_DATE='946684801 +0000' git commit-tree "$@" </dev/null
 }
 clean-commit $tree >.git/refs/heads/master
 
 # Pack things up nicely.
-git-repack -a >/dev/null
+git repack -a >/dev/null
 for i in pack idx; do
        mv .git/objects/pack/{pack*.$i,pack.$i}
 done
-git-prune >/dev/null
+git prune >/dev/null
 
 # Write out git repository as a Matt-style file tree.
 function write_file {
diff --git a/retex b/retex
index d603e2e..447aa71 100755 (executable)
--- a/retex
+++ b/retex
@@ -1,27 +1,50 @@
 #!/bin/bash
-# Well-behaved repeating TeX builder -- Matt McCutchen
-# usage: retex <cmd> <input-file-minus-.tex>
+# usage: retex [--bibtex] CMD INPUTNAME (without .tex)
 
 set -e
 
+# Add a bibtex option for the streaming notes.
+# Since the bibtex needs to be part of the fixed-pointing, I unfortunately don't
+# see a better way to handle it than as part of retex.  - Matt 2008-09-02
+if [ "$1" == --bibtex ]; then
+       bibtex=1
+       shift
+fi
+
+if [ $# != 2 ]; then
+       echo >&2 'usage: retex [--bibtex] CMD INPUTNAME (without .tex)'
+       exit 1
+fi
+
 cmd="$1"
 in="$2"
 shift 2
 
+# Just Work if passed `foo.tex'.
+if [ "$in" != "${in%.tex}" ]; then
+       in="${in%.tex}"
+fi
+
 function run {
+       if [ $bibtex ] && [ -r "$in.aux" ]; then
+               echo "[$iter] Running bibtex..."
+               bibtex "$in.aux"
+               # Work around \href commands getting line-broken in places that
+               # break things ~ Matt 2010-12-17
+               sed -i -e '/%$/{N; s/%\n//}; /\\href$/{N; s/\n/ /}' "$in.bbl"
+       fi
        echo "[$iter] Running $2..."
-       yes X | "$cmd" -file-line-error-style "$in"
+       "$cmd" -file-line-error -halt-on-error "$in"
 }
 
 function compare {
        echo "Comparing files..."
-       for f in "$in"*; do
+       for f in "$in."*; do
                # ignore pdfs because they have a nonreproducible "ID" at the end
-               # and logs because they aren't read
-               if ! [ "$f" != "${f%.keep*}" ] && ! [ "$f" != "${f%.pdf}" ] \
-                       && ! [ "$f" != "${f%.log}" ]; then
-                       suf="${f#$in}"
-                       cmp "$in$suf" "$in.keep$suf" || return $?
+               # and logs because they have a less-reproducible time; neither are read
+               if [ "$f" == "${f#$in.retex-keep.}" ] && [ "$f" == "${f%.pdf}" ] && [ "$f" == "${f%.log}" ]; then
+                       suf="${f#$in.}"
+                       cmp "$in.retex-keep.$suf" "$in.$suf" || return $?
                fi
        done
        echo "Reached a fixed point."
@@ -29,28 +52,22 @@ function compare {
 
 function keep {
        echo "Keeping files..."
-       for f in "$in"*; do
-               if ! [ "$f" != "${f%.keep*}" ]; then
-                       suf="${f#$in}"
-                       \cp -p "$in$suf" "$in.keep$suf"
+       for f in "$in."*; do
+               if [ "$f" == "${f#$in.retex-keep.}" ]; then
+                       suf="${f#$in.}"
+                       cp "$in.$suf" "$in.retex-keep.$suf"
                fi
        done
 }
 
 function clean {
        echo "Cleaning up kept files..."
-       rm -f "$in.keep"*
-}
-
-function fail {
-       echo "Compiler exited with code $1."
-       # Remove output files here, a la .DELETE_ON_ERROR?
-       exit $1
+       rm -f "$in.retex-keep."*
 }
 
 iter=0
 keep
-run || fail $?
+run || exit $?
 limit=10
 while ! compare; do
        iter=$(($iter + 1))
@@ -59,7 +76,7 @@ while ! compare; do
                exit 2
        fi
        keep
-       run || fail $?
+       run || exit $?
 done
 clean
 echo "Successful."
diff --git a/stat2 b/stat2
index e3b9845..896758a 100755 (executable)
--- a/stat2
+++ b/stat2
@@ -13,7 +13,10 @@ while [ "$#" != "0" ] ; do
                getfacl --absolute-names --tabular -- "$1" | tail -n +2 | head -n -1 | sed -e "s/^/$indent/"
        fi
        echo "+-- Extended attributes in all namespaces from \`getfattr':"
-       getfattr --absolute-names -h -d -m '' -- "$1" | tail -n +2 | head -n -1 | sed -e "s/^/$indent/"
+       # Add -P, otherwise the getfattr command printed xattrs of subdirectories
+       # when passed ~/cc (a symlink).  I think this is a bug.  TODO: report it.
+       # ~ 2010-05-16
+       getfattr --absolute-names -h -d -m '' -P -- "$1" | tail -n +2 | head -n -1 | sed -e "s/^/$indent/"
        echo "'---------------------------------------"
        shift
 done
diff --git a/ungitar b/ungitar
index 8a6d468..061a849 100755 (executable)
--- a/ungitar
+++ b/ungitar
@@ -15,5 +15,5 @@ fi
 trap "rm -rf .git" EXIT
 
 ftx .git
-git-read-tree master
-git-checkout-index --all --force
+git read-tree master
+git checkout-index --all --force