[squeak-dev] Re: a slim holiday present, cpic

Eliot Miranda eliot.miranda at gmail.com
Sun Mar 6 18:11:04 UTC 2011


Argh!  Here's a fix to a bad bug in the last version (cp "$1.image"
"$1.changes" "$d" => cp "$1.image" "$1.changes" "$2")!!
-------8<-------
#!/bin/sh
# copy image and changes
force=0
if [ "$1" = -f ]; then
force=1
shift
fi
if [ $# != 2 -o "$1" = "-?" -o "$1" = --help ]; then
echo "usage: $0 [-f] image-name-no-ext [image-name-no-ext|dir]"
test $# != 2 && exit 1
exit 0
fi
if [ -f "$2.image" -o -f "$2.changes" ]; then
if [ "$force" = 0 ]; then
echo "$2.image and/or $2.changes already exist." 1>&2
exit 1
fi
elif [ -d "$2" ]; then
if [ -f "$2/`basename "$1"`.image" -o -f "$2/`basename "$1"`.changes" ];
then
if [ "$force" = 0 ]; then
echo "$2/`basename "$1"`.image and/or $2/`basename "$1"`.changes already
exist." 1>&2
exit 1
fi
fi
cp "$1.image" "$1.changes" "$2"
exit 0
fi
cp "$1.image" "$2.image"
cp "$1.changes" "$2.changes"


On Fri, Dec 17, 2010 at 2:33 PM, Eliot Miranda <eliot.miranda at gmail.com>wrote:

> Hi All,
>
>     don't know if this is useful to you or whether you've already written
> it yourself but I finally caved and wrote a shell command that copies an
> image/changes file pair, replacing the hundreds of times I've issued the two
> parallel commands, cpic = copy image and changes.  Happy holidays
> -------8<-------
> #!/bin/sh
> # copy image and changes
> force=0
> if [ "$1" = -f ]; then
>     force=1
>     shift
> fi
> if [ $# != 2 -o "$1" = "-?" -o "$1" = --help ]; then
>     echo "usage: $0 [-f] image-name-no-ext [image-name-no-ext|dir]"
>     test $# != 2 && exit 1
>     exit 0
> fi
> if [ -f "$2.image" -o -f "$2.changes" ]; then
>     if [ "$force" = 0 ]; then
>         echo "$2.image and/or $2.changes already exist." 1>&2
>         exit 1
>     fi
> elif [ -d "$2" ]; then
>     if [ -f "$2/$1.image" -o -f "$2/$1.changes" ]; then
>         if [ "$force" = 0 ]; then
>             echo "$2/$1.image and/or $2/$1.changes already exist." 1>&2
>             exit 1
>         fi
>     fi
>     cp "$1.image" "$1.changes" "$d"
>     exit 0
> fi
> cp "$1.image" "$2.image"
> cp "$1.changes" "$2.changes"
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20110306/4dec3ab9/attachment.htm


More information about the Squeak-dev mailing list