Alien-Judy

 view release on metacpan or  search on metacpan

src/judy-1.0.5/tool/README  view on Meta::CPAN

# 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.



( run in 0.907 second using v1.01-cache-2.11-cpan-13bb782fe5a )