Salve Tzafrir!

On Sat, 08 Jul 2006, Tzafrir Cohen wrote:
> > sslash=$(echo $1 | sed 's/[^/]//g')
> use 'basename' instead?

Good idea, sp=${1%/*} creats trouble
when there is no slash inside $1 ....

> You should exit with an error if you did not deliver a call file.
> exit 1
> 
> Also, to make this a little less bashist:
> 
> if [ "$sf" = '' ]; then
Ok. 
[ ! "$sf" ] instead would be bashist?

Good night,
rob

#!/bin/bash 
# set -e
# cpmv by [EMAIL PROTECTED] 2006-08-07
# Thanks to Tzafrir Cohen for tips ;)
# Like with BSD-licence, do with it, 
# what you like.         Why cpmv?
# cp is not atomic and not reliable
# and makes trouble e.g. when you cp
# files to /var/spool/asterisk/outgoing.
#
# cpmv copy to /tmp first, and move then.
# cpmv don't work with wildcards ('*' '?')
# store it in e.g. /usr/bin/cpmv
# use like mv: "cpmv dir1/source dir2/target"
#############################################

if [ "$2" = '' ]; then
   echo 'source or target is missing, aborted'  
   exit 1
fi
if [ "$3" != '' ]; then
   echo 'to much input, aborted'        
   exit 1
fi
if [ "$1" = "$2" ]; then
   echo 'source = target, aborted'      
   exit 1
fi
if [ -d "$2" ]; then
   echo 'target is a directory, aborted'
   exit 1
fi   

sourcefilename=$(basename $1)
target=$2
if [ "$2" = '.' ]; then
   target=$sourcefilename
fi
tmp=$(mktemp /tmp/$sourcefilename.cpmv.XXXXXXXXXX)
cp -p $1 $tmp; mv $tmp $target
# EOF


 
_______________________________________________
--Bandwidth and Colocation provided by Easynews.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Reply via email to