#!/bin/rc -e
fn usage { echo 'pack source source ...'}
#
# GOAL:
# foo -> foo.gz in case of file.
# foo -> foo.tgz in case of dir.
# foo.tar -> foo.tgz
# *.gz -> DO NOTHING
#
# code by Kenar
#
rfork e
fn usage {
echo 'usage: pack file ...'
exit usage
}
fn error {
echo $*
exit 'not found'
}
if(~ $#* 0) usage
while (! ~ $#* 0){
x=$1
if (test ! -e $x) error file $x not found
f = 1
while(~ $f 1){
switch($x){
case *.gz *.tgz
f=0
case *.tar
gzip $x
echo rm $x
f=0
case *
if(test -d $x){
tar -pcf $x.tar $x
echo rm -rf $x
x=$x.tar
}
if not{
gzip $x
echo rm $x
f=0
}
}
}
shift
}
|