#!/bin/ash
# rustic `ls` (by M. Andreoli)
# 

#set -x
myself=/bin/ls
SIZE=/bin/size
PR=/bin/pr

#Syntax

opt=$1

case $opt in
-R) shift;;
-h) echo "Usage (mu-ls): ls -[h|l] files" ; exit ;;
-*) shift;;
*)
esac



# print the list

print()
{
files=$*
for f in $files
do

if   [ -d "$f" ] ; then
type='/'
elif [ -L "$f" ]; then
type='@'
elif [ -f "$f" ]; then
type=''
else
type=unset
fi


if [ Z"$opt"Z != "Z-lZ" ] ; then
        echo  "$f$type"
else
	size=`$SIZE $f`
        echo   "$f$type:$size"
fi	

done
}

# Main

case $# in
0) 
	print * | $PR -4  
	;;
1)	
	if [ -d "$1" ] ; then
		cd $1
		print * | $PR -4
	else
		print $1	
	fi

	;;
*)
	for f in $*
	do
	$myself $opt $f
	done
	
esac
