Home
       uninstall - scc - simple c99 compiler
  HTML git clone git://git.simple-cc.org/scc
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
   DIR README
   DIR LICENSE
       ---
       uninstall (550B)
       ---
            1 #!/bin/sh
            2 
            3 set -e
            4 
            5 for i
            6 do
            7         case "$i" in
            8         -p)
            9                 proto=$2
           10                 shift 2
           11                 ;;
           12         -*)
           13                 echo usage: uninstall [-p proto] root >&2
           14                 exit 1
           15                 ;;
           16         esac
           17 done
           18 
           19 root=${1?'root missed'}
           20 proto=${proto:-scripts/proto.all}
           21 
           22 while read type perm name
           23 do
           24         case $type in
           25         d)
           26                 echo $type $perm $name
           27                 continue
           28                 ;;
           29         f)
           30                 rm -f $root/$name
           31                 ;;
           32         *)
           33                 echo install: wrong entry type >&2
           34                 exit 1
           35                 ;;
           36         esac
           37 done < $proto |
           38 sort -r |
           39 while read type perm name
           40 do
           41         case $type in
           42         d)
           43                 if test `ls $root/$name | wc -l` -eq 0
           44                 then
           45                         rmdir $root/$name
           46                 fi
           47                 ;;
           48         esac
           49 done