Received:

Peter da Silva peter at ficc.ferranti.com
Sun Sep 9 23:25:35 AEST 1990


In article <1990Sep9.004235.11572 at usenet.ins.cwru.edu> chet at po.CWRU.Edu writes:
> Peter da Silva writes:
> $ ls()
> $ {
> $ 	for i
> $ 	do
> $ 		echo $i
> $ 	done
> $ }

> Useful, that.

When hacking around on a floppy-booted UNIX system, yes.

> Creative use of `[ -f $i -o -d $i ]' is needed, I think.

Well, it might be desirable, but anyone screwing with the UNIX on their
boot floppy is probably up to noticing the difference. But, if you insist:

# Anal-retentive ls() for boot floppies... dare to type it in!
#
# UNTESTED!!!!!
#
ls()
{
  RECURSE=-d
  TYPE=0
  DIR=0
  for i
  do
    case ".$i" in
      .-F) TYPE=1;;
      .-R) RECURSE=;;
      .-d) DIR=1;;
      .-*) echo "Option $i not implemented.";;
      *)
        if [ -f $i -o -d $i ]
	then
	  if [ $TYPE = 1 -a -x $i ]
	  then
	    echo "$i*"
	  elif [ $TYPE = 1 -a $DIR = 1 -a -d $i ]
	  then
	    echo "$i/"
	  elif [ $DIR = 0 -a -d $i ]
	  then
	    DIRS="$DIRS $i"
	  else
	    echo "$i"
	  fi
	else
	  echo "$i not found"
	fi
	;;
    esac
  done
  for i in $DIRS
  do
    echo "\n$i:"
    ls $RECURSE $i
  done
}
-- 
Peter da Silva.   `-_-'
+1 713 274 5180.   'U`
peter at ferranti.com



More information about the Comp.unix.internals mailing list