[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lazy man's "pkg_delete" (terrible script - help!)



cd /var/db/pkg; pkg_delete xm*

1) your version (without the cd) leaves the shell to expand xm* which
   varies, depending on the cwd.
2) bash is not part of openbsd.  Please leave your linux haven
   and understand that many things port easily to Linux, but
   many Linux programmers write crap that can't be ported out
   of Linux.  Use the Posix shell.
3) it would be handy if pkg_* would strip off paths for
   pkg_delete /var/db/pkg/xm*  to work.

Quoting poff@sixbit.org (poff@sixbit.org):
> Hi,
> 
> I was a bit shocked to find pkg_delete xm* wouldn't work, and that one has
> to type in the full name and version of the file, or I'm missing
> something...
> 
> So I whipped togetherthis dreadful script (shame!) and was wondering if
> someone could improve it for me? I new to shell scripting...
> 
> # cat /usr/local/bin/pkgdelete
> #!/usr/local/bin/bash
> 
> if [ ! $1 ]; then
>         echo "please enter partial package name"
> else
>         match=`pkg_info | awk '{print $1}' | grep $1`
>         matches=`echo $match | wc -w | sed -e "s/[ ]*[  ]*//"`