Skip to content
/ fh Public

file history with ed(1), diff(1), awk(1), sed(1) and sh(1)

License

Notifications You must be signed in to change notification settings

xorhash/fh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

file history with ed(1), diff(1), awk(1), sed(1) and sh(1)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published