1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-19 06:36:15 +02:00

dsv/dsv: allow -p and -u to be used together

In this case, first the path and then the URL is printed.
Before, you'd either get and error or one of the options would be ignored.
This commit is contained in:
Werner Almesberger 2012-12-22 22:31:27 -03:00
parent 676c6a2715
commit bbb6513b42

44
dsv/dsv
View File

@ -30,7 +30,7 @@ DSV_DIR=.dsv
usage() usage()
{ {
echo "usage: $0 [-p|-u] <component>" 2>&1 echo "usage: $0 [-p] [-u] <component>" 2>&1
echo " $0 help" 2>&1 echo " $0 help" 2>&1
echo " $0 [ls]" 2>&1 echo " $0 [ls]" 2>&1
echo " $0 setup <info-file> ..." 2>&1 echo " $0 setup <info-file> ..." 2>&1
@ -158,17 +158,6 @@ search()
if [ -d $DSV_DIR ]; then if [ -d $DSV_DIR ]; then
name=`echo "$1" | sed 's/%/%25/g;s|/|%2F|g'` name=`echo "$1" | sed 's/%/%25/g;s|/|%2F|g'`
if [ -r "$DSV_DIR/dsv-$name" ]; then if [ -r "$DSV_DIR/dsv-$name" ]; then
if $show_url; then
url=`sed 1d "$DSV_DIR/dsv-$name"`
if [ "$url" ]; then
echo "$url"
exit
else
echo "$DSV_DIR/dsv-$name" \
"does not contain an URL - please regenerate" 1>&2
exit 1
fi
fi
file=`sed 1q "$DSV_DIR/dsv-$name"` file=`sed 1q "$DSV_DIR/dsv-$name"`
if [ ! -r "$DSV_DIR/$file" ]; then if [ ! -r "$DSV_DIR/$file" ]; then
echo "$1 -> $file: does not exist" 2>&1 echo "$1 -> $file: does not exist" 2>&1
@ -176,9 +165,19 @@ search()
fi fi
if $path; then if $path; then
echo "`pwd`/$DSV_DIR/$file" echo "`pwd`/$DSV_DIR/$file"
else elif ! $show_url; then
${DSV_VIEWER:-${DSV_PDFVIEWER:-xdg-open}} "$DSV_DIR/$file" ${DSV_VIEWER:-${DSV_PDFVIEWER:-xdg-open}} "$DSV_DIR/$file"
fi fi
if $show_url; then
url=`sed 1d "$DSV_DIR/dsv-$name"`
if [ "$url" ]; then
echo "$url"
else
echo "$DSV_DIR/dsv-$name" \
"does not contain an URL - please regenerate" 1>&2
exit 1
fi
fi
exit exit
fi fi
fi fi
@ -192,14 +191,17 @@ search()
path=false path=false
show_url=false show_url=false
if [ "$1" = -p ]; then
path=true while true; do
shift case "$1" in
fi -p) path=true
if [ "$1" = -u ]; then shift;;
show_url=true -u) show_url=true
shift shift;;
fi -*) usage;;
*) break;;
esac
done
case "$1" in case "$1" in
help|-*) usage;; help|-*) usage;;