#!/bin/sh
# find executables that aren't stripped
# Because of limitiation of `file`, files
# with : in name will not be processed correctly
# Also note, don't sort by size before `file`
# since there will be more seeking over disk and
# therefore will be much slower.

. fslver

Usage() {
	ProgName=`basename "$0"`
	echo "find NonStripped executables.
Usage: $ProgName [[-r] [-f] paths(s) ...]

If no path(s) specified then the PATH is searched."
	exit
}

if [ $# -eq "0" ] #Nothing on cmdline means search binary directories
then
	findArgs=`. getffp`
	FPF="%p"
else
	for arg
	do
		case "$arg" in
		-h|--help|-help)
			Usage ;;
		-v|--version)
			Version ;;
		*)
			argsToPassOn="$argsToPassOn $arg" ;;
		esac
	done
	set -f #no globbing
	. getfpf "$argsToPassOn"
fi

find $findArgs -type f -perm +111 -printf "%i\t$FPF\n" |
#sorting by inodes runs in 17s for my 2250 binaries
#compared to 20s without
sort -k1,1n |
cut -f2- |
tr '\n' '\0' |
xargs -r0 file |
grep -E " executable.+ not stripped" |
cut -f1 -d: -s |
if [ -p /proc/self/fd/1 ]; then
    cat
else
    tr '\n' '\0' |
    xargs -r0 ls -Ulb -- |
    sort -b -k5,5n
fi
