#!/bin/sh

USAGE="Usage $0 [-i] files"

ASK=false
VERBOSE=:

ECHO=/usr/ucb/echo

set -- `getopt iv $*`
if [ $? != 0 ]
then
	$ECHO $USAGE
	exit 2
fi

for i in $*
do
    case $i in
	-i) ASK=true; shift;;
	-v) VERBOSE=	; shift;;
	--) shift; break;;
	esac
done

files=`file $* | \
	egrep -e "ELF.*executable.*not stripped" | \
	awk -F: '{print $1}'`

for f in $files
do
	$VERBOSE ls -l $f
	if $ASK
	then
		$ECHO -n "strip $f [ny]? "
		read reply junk
	else
		reply=y
	fi

	if [ "$reply" = y ]
	then
		strip $f
		$VERBOSE ls -l $f
	fi
	$ECHO
done
