+usage() {
+ cat <<EOF
+usage: $0 SUBVOL_MOUNTPOINT...
+
+In git this is not not executable because it's meant to be installed
+using ./install-my-scripts
+
+If latest subvols \$@ are not mounted, print a message, and print
+the unstale subvol name into /nocow/btrfs-stale/\$subvol
+
+Fresh is opposite of stale. To be fresh, either SUBVOL_MOUNTPOINT is a
+snapshot of the latest, or the latest snapshot is snapshot of
+SUBVOL_MOUNTPOINT.
+
+-d Enable debug output
+-h|--help Print help and exit.
+
+Note: Uses GNU getopt options parsing style
+EOF
+ exit $1
+}
+
+##### begin command line parsing ########
+
+debug=false # default
+temp=$(getopt -l help,d hd "$@") || usage 1
+eval set -- "$temp"
+while true; do
+ case $1 in
+ -d) debug=true; shift ;;
+ -h|--help) usage ;;
+ --) shift; break ;;
+ *) echo "$0: Internal error! unexpected args: $*" ; exit 1 ;;
+ esac
+done
+
+if [[ ! $1 ]]; then
+ echo "$0: error: expected mountpoint argument"
+fi
+
+stale-file() {
+ stale_dir=/nocow/btrfs-stale
+ stale_file=$stale_dir/$vol
+ if $stale; then
+ mkdir -p $stale_dir
+ printf "%s\n" $freshest_snap > $stale_file
+ else
+ rm -f $stale_file
+ fi
+
+}
+d() {
+ if $debug; then
+ printf "%s\n" "$*"
+ fi
+}
+