logging: Check if typescripts with a similar name already exist
[sunny256-utils.git] / git-restore-dirs
blobadf4efefad0e91088fcdb5858ed8fcea9f688f89
1 #!/bin/sh
3 #==============================================================================
4 # git-restore-dirs
5 # File ID: 14434f48-6be7-11df-904a-90e6ba3022ac
7 # Restore empty directories created by git-store-dirs(1)
9 # Author: Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later.
11 #==============================================================================
13 progname=git-restore-dirs
14 VERSION=0.3.0
16 opt_help=0
17 opt_quiet=0
18 opt_verbose=0
19 while test -n "$1"; do
20 case "$1" in
21 -h|--help) opt_help=1; shift ;;
22 -q|--quiet) opt_quiet=$(($opt_quiet + 1)); shift ;;
23 -v|--verbose) opt_verbose=$(($opt_verbose + 1)); shift ;;
24 --version) echo $progname $VERSION; exit 0 ;;
25 --) shift; break ;;
27 if printf '%s\n' "$1" | grep -q ^-; then
28 echo "$progname: $1: Unknown option" >&2
29 exit 1
30 else
31 break
33 break ;;
34 esac
35 done
36 opt_verbose=$(($opt_verbose - $opt_quiet))
38 if test "$opt_help" = "1"; then
39 test $opt_verbose -gt 0 && { echo; echo $progname $VERSION; }
40 cat <<END
42 Restore empty directories created by git-store-dirs(1).
44 Usage: $progname [options]
46 Options:
48 -h, --help
49 Show this help.
50 -q, --quiet
51 Be more quiet. Can be repeated to increase silence.
52 -v, --verbose
53 Increase level of verbosity. Can be repeated.
54 --version
55 Print version information.
57 END
58 exit 0
61 tmppref=$(date -u +"%Y%m%dT%H%M%SZ").$$
62 bef_file=/tmp/grd.$tmppref.before.tmp
63 aft_file=/tmp/grd.$tmppref.after.tmp
64 dirfile=.emptydirs
65 test -e $dirfile || { echo $0: No $dirfile file found >&2; exit 1; }
66 emptydirs >$bef_file
67 xargs -0 mkdir -p <$dirfile
68 emptydirs >$aft_file
69 diff -u $bef_file $aft_file | grep '^+\./' | cut -c 2-
70 rm $bef_file $aft_file
72 # vim: set ts=8 sw=8 sts=8 noet fo+=w tw=79 fenc=UTF-8 :