File: cvs-adjustroot

package info (click to toggle)
chiark-utils 4.1.10
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 752 kB
  • ctags: 482
  • sloc: perl: 2,902; ansic: 1,951; sh: 777; makefile: 260; tcl: 228
file content (27 lines) | stat: -rwxr-xr-x 517 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash

set -e

usage () { echo >&2 'usage: cvs-adjustroot OLD NEW'; exit 1; }

case "$#.$1" in
4.--reinvoke)	reinvoke=true; shift	;;
*.-*)		usage			;;
2.*)		reinvoke=false		;;
1.*)		usage			;;
0.*)		usage			;;
*)		usage			;;
esac

old="$1"; shift
new="$1"; shift

if $reinvoke; then
	filename="$1";
	cmp -- "$filename" <(printf "%s\n" "$old")
	printf "%s\n" "$new" >"$filename".new
	mv -f -- "$filename".new "$filename"
	exit 0
fi

find -path '*/CVS/Root' -exec cvs-adjustroot --reinvoke "$old" "$new" '{}' ';'