Skip to content
file history with ed(1), diff(1), awk(1), sed(1) and sh(1)
Branch: master
Clone or download
Latest commit d844d80 May 3, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore Initial commit Apr 19, 2019
LICENSE Initial commit Apr 19, 2019
README.md README: note how to convert -mdoc to -man Apr 20, 2019
fh.5 fh.5: use .Fl e over -e May 3, 2019
fl Initial commit Apr 19, 2019
fl.1 Initial commit Apr 19, 2019
fr fr: die on invalid option May 3, 2019
fr.1 Initial commit Apr 19, 2019
fu fu: add -c option May 3, 2019
fu.1 fu: add -c option May 3, 2019
man.md Initial commit Apr 19, 2019

README.md

fh: file history

fh records changes to a file on a per-file basis, similar to RCS and SCCS. It is, however, considerably more primitive.

Design goals:

  • no support for multi-user environments (no locking, etc.)
  • implemented in shell script
  • must use ed(1)
  • should work or easily be made to work on 7th Edition UNIX

I've taken care not to use any shell scripting constructions that didn't exist in the Bourne shell, but I may have missed things; however, the shebang needs to be removed on 7th Edition UNIX.

fh uses a chain of ed(1) scripts to construct any version of a file. It even allows recording of commit messages.

Why?

I saw the following passage in diff(1) of 7th Edition UNIX:

The -e option produces a script of a, c and d commands for the editor ed, which will recreate file2 from file1. The -f option produces a similar script, not useful with ed, in the opposite order. In connection with -e, the following shell program may help maintain multiple versions of a file. Only an ancestral file ($1) and a chain of version-to-version ed scripts ($2,$3,...) made by diff need be on hand. A `latest version' appears on the standard output.

(shift; cat $*; echo ´1,$p´) ⎪ ed - $1

After some thinking, I figured it would be hilarious to actually implement a basic version control system on these primitives. In hindsight, it's probably closer to terrifying than hilarious.

License

ISC, see LICENSE.

Installation and usage

Copy the fl, fr and fu files to a directory in $PATH; make sure they are marked as executable. Copy the man pages fl.1, fr.1, fu.1 and fh.5 to a directory in $MANPATH.

For usage, see the supplied man pages. man.md is available on the web. For 7th Edition UNIX, the man pages written in mdoc macrosneed to be converted to old man macros first:

mkdir man
mandoc -Tman fl.1 > man/fl.1
mandoc -Tman fr.1 > man/fr.1
mandoc -Tman fu.1 > man/fu.1
mandoc -Tman fh.5 > man/fh.5
You can’t perform that action at this time.