Skip to content

Instantly share code, notes, and snippets.

@cmcaine
cmcaine / swap
Last active October 13, 2016 00:48
Swap two files reasonably safely
#!/bin/sh
# Swap two files safely.
#
# Under normal circumstances, just do the right thing. Under unusual
# circumstances, give a reasonably helpful error message.
#
# This was an exercise in thinking about how generally reliable functions might
# fail and what to communicate to users.
#
# Copyright Colin Caine. License: GPLv2