std/c/README.md: Add section skeletons and don't indent lists
[sunny256-utils.git] / mkcvsbck
blob97acdba618e7888b2419642c9227ac913753884d
1 #!/usr/bin/env bash
3 #=======================================================================
4 # mkcvsbck
5 # File ID: ed0eac02-5d3f-11df-9313-90e6ba3022ac
6 # I’m getting spoiled by having a text-base around when working in
7 # Subversion, CVS doesn’t have that. So if I’ve edited a file without
8 # making a copy of the original, a new version of the file has to be
9 # checked out manually. This script automates that task.
10 #=======================================================================
12 fname=$1
13 fbck=$fname.bck
14 ftmp=$fname.tmp
16 if [ "$fname" = "" ]; then
17 echo "Syntax: $0 filename" >&2
18 exit 1
21 if [ -e $fbck ]; then
22 echo -n "$0: $fbck: File already exists. Press Enter to remove it, Ctrl-C to abort..." >&2
23 read
24 rm -v $fbck || { echo "$0: $fbck: Cannot remove file" >&2; exit 1; }
27 if [ -e $ftmp ]; then
28 echo "$0: $ftmp: Temporary file already exists" >&2
29 exit 1
32 if [ ! -f $fname ]; then
33 echo "$0: $fname: Not a regular file" >&2
34 exit 1
37 mv -v $fname $ftmp || { echo "$0: mv $fname $ftmp: Error when renaming to tempfile" >&2; exit 1; }
38 cvs update $fname
40 if [ ! -e $fname ]; then
41 echo "$0: $fname: Yikes! Couldn’t check out original file, moving tempfile back" >&2
42 mv -v $ftmp $fname || { echo "$0: mv $ftmp $fname: Shit! Unable to rename tempfile to workfile" >&2; }
43 exit 1
46 mv -v $fname $fbck || { echo "$0: mv $fname $fbck: Couldn’t rename to backup file" >&2; exit 1; }
47 mv -v $ftmp $fname || { echo "$0: mv $ftmp $fname: Couldn’t rename tempfile to workfile" >&2; exit 1; }
49 ls -la $fname $fbck