File: README

package info (click to toggle)
judy 1.0.3-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 5,540 kB
  • ctags: 2,566
  • sloc: ansic: 24,975; sh: 9,565; makefile: 394
file content (134 lines) | stat: -rw-r--r-- 3,495 bytes parent folder | download | duplicates (7)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134

# @(#) $Revision: 4.2 $

# CHECK README FILES AGAINST DIRECTORIES.

# Usage: <script> [-b] [dir ...]
#
# -b:  Compare files by basenames only (in case of fuller paths in the README
# file), except for trailing slashes or at-signs on directory names.
#
# For caller convenience, if a "dir" argument ends in "/README", that part is
# ignored and the rest is taken as the directory name.

# Checks the current directory by default, else the the named directories.
# Reads $file (see below) in each directory.  Takes the first field of each
# line which starts in column 1 and is not a comment ("#") as a filename, and
# compares it (or its basename) against the files in the directory, except for
# README itself and ".sbcm", the ubiquitous Softbench CM cache file created in
# many source directories.

# Defect:  If there are two files, one a directory and the other a superset of
# the first file's name, they are mis-sorted due to the trailing slash on the
# directory, and one shows up as both present and missing.

##############################################################################
# Here's a sample README file that works with this program, ignoring the
# comment marks in the first column.
# _________________
#
# # @(#) $Revision: 4.2 $
# # This directory contains blah blah blah...
#
# # IMPORTANT FILES:
#
# foobar	A silly file containing lots of stuff
#		that only its mother could love.
#
# barfoo	The opposite.
#
#
# # LESS IMPORTANT FILES:
#
# bagle		Document titled, "In the Beginning, ..."
#
# beagle	Another document, titled "Then There was Darwin"
#
##############################################################################


# CHECK ARGUMENTS, INITIALIZE:

	if [[ "x$1" = x-b ]]		# -b option.
	then optb='yes'; shift
	else optb=''
	fi

	if [[ $# = 0 ]]			# no args given.
	then telldir=''; set .		# use PWD, ".".
	else telldir='yes'
	fi

	file='README'			# to read and check in each directory.

	temp1="/tmp/readme1$$"
	temp2="/tmp/readme2$$"
	trap "rm -f $temp1 $temp2; exit "'$retval' 0 1 2 3 15

	tab='	'
	retval='0'			# default return value.


# EXTRACT FILENAMES FROM README FILE:
#
# If $dir ends in "/README", strip that part as a convenience to the caller.

	for dir in "$@"
	do
	    dir="${dir%/README}"

# Since this whole script is a checker, write the following message to stdout,
# not stderr:

	    if [[ ! -f "$dir/$file" ]]
	    then echo "$0: cannot find $dir/$file file"; retval='1'; continue
	    fi

# Print field 1 if it starts in column 1 and isn't a comment or a README or
# .sbcm file, optionally the basename part only (except for trailing "/"):

	    awk < "$dir/$file" '

	    (NF > 0) && ($0 !~ /^[ '"$tab"'#]/) {

		if ($1 == "README") next;
		if ($1 == ".sbcm" ) next;

		if ("'"$optb"'" == "yes")
		    while ((at = index ($1, "/")) && (at < length ($1)))
			$1 = substr ($1, at + 1);

		print $1;
	    }' |

	    sort -u > $temp1


# COMPARE:
#
# Add "/" to directory names, but remove "*" from executable file names.
# Also ignore "README" and ".sbcm" files themselves, and "." and ".." files.
# Sort the results because ls -F lists "x/" before "x.y/", and sort reverses
# them.

	    ls -aF $dir |

	    sed	-e 's/\*$//' \
		-e '/^README$/d' \
		-e '/^\.sbcm$/d' \
		-e '/^\.\/$/d' \
		-e '/^\.\.\/$/d' |

	    sort | comm -3 $temp1 - > $temp2

	    if [[ -s $temp2 ]]			# not empty.
	    then
		[[ -n "$telldir" ]] && echo "\n$dir:"
		echo "README\tdirectory"
		cat $temp2
		retval='1'
	    fi
	done

	exit $retval
ironment.