I've written a (poor) script for displaying information about ports, but one of the command line options is not working as expected.
When I specify the option "-m", I get the message
followed by the expected output:
All the command line options have been set the same way (no doubt not the best way) but only this option misbehaves.
Here is the script in full:
When I specify the option "-m", I get the message
Code:
[: -m: unexpected operator
% ./pdesc.sh -m wmii
Code:
[: -m: unexpected operator
devel/libixp
x11/bigreqsproto
x11/xcmiscproto
x11/xtrans
x11-fonts/xf86bigfontproto
devel/libcheck
x11/xcb-proto
textproc/libxslt
security/libgcrypt
security/libgpg-error
All the command line options have been set the same way (no doubt not the best way) but only this option misbehaves.
Here is the script in full:
Code:
#!/bin/sh
# This script will allow users to search the ports tree and display port categories, ports names and port descriptions.
# Set a few useful variables
pdir="/usr/ports"
# Usage:
# pdesc [-h] - print this help
# pdesc [-c [category name]] - list all categories, or contents therein
# pdesc [-n port-name] - display pkg-descr contents for given port
# pdesc [-s string] - search for given port
# pdesc [-d port-name] - print all dependencies for given port
# pdesc [-b port-name] - print build dependencies for given port
# pdesc [-m port-name] - print mising dependencies for given port
if [ -z $1 ]
then
echo "Usage:
pdesc [-h] - print this help
pdesc [-c [category name]] - list all categories, or contents therein
pdesc [-n port-name] - display pkg-descr contents for given port
pdesc [-s string] - search for given port
pdesc [-d port-name] - print all dependencies for given port
pdesc [-b port-name] - print build dependencies for given port
pdesc [-m port-name] - print mising dependencies for given port
"
elif [ $1 = -h ]
then
echo "Usage:
pdesc [-h] - print this help
pdesc [-c [category name]] - list all categories, or contents therein
pdesc [-n port-name] - display pkg-descr contents for given port
pdesc [-s string] - search for given port
pdesc [-d port-name] - print all dependencies for given port
pdesc [-b port-name] - print build dependencies for given port
pdesc [-m port-name] - print mising dependencies for given port
"
elif [ $1 = -c ] && [ -z $2 ]
then
ls -d $pdir/*/ | sed s:$pdir/:: | column
elif [ $1 = -c ] && [ -d $pdir/$2 ]
then
ls -d $pdir/$2/*/ | sed s:$pdir/$2/:: | column
elif [ $1 -n ] && [ -z $2 ]
then
echo "The -n option requires a valid name of a port."
elif [ $1 = -n ]
then
more $pdir/*/$2/pkg-descr
elif [ $1 = -s ] && [ -z $2 ]
then
echo "The -s options requires a search pattern."
elif [ $1 = -s ] && [ -n $2 ]
then
find $pdir/* -maxdepth 1 -iname *$2* | sed s:$pdir/:: | column
elif [ $1 = -d ] && [ -z $2 ]
then
echo "The -d option requires a valid port name."
elif [ $1 = -d ] && [ -n $2 ]
then
make -C $pdir/*/$2 all-depends-list
elif [ $1 = -b ] && [ -z $2 ]
then
echo "The -b option requires a valid port name."
elif [ $1 = -b ] && [ -n $2 ]
then
elif [ $1 = -m ] && [ -z $2 ]
then
echo "The -m option requires a valid port name."
elif [ $1 = -m ] && [ -n $2 ]
then
make -C $pdir/*/$2 missing
fi