diff --git a/dsv/dsv b/dsv/dsv index 1496ffd..d623cbe 100755 --- a/dsv/dsv +++ b/dsv/dsv @@ -30,12 +30,13 @@ DSV_DIR=.dsv usage() { - echo "usage: $0 [-p] " 2>&1 + echo "usage: $0 [-p|-u] " 2>&1 echo " $0 help" 2>&1 echo " $0 [ls]" 2>&1 echo " $0 setup ..." 2>&1 echo 2>&1 echo " -p show the path instead of displaying the file " 2>&1 + echo " -u show source URL instead of displaying the file " 2>&1 exit 1 } @@ -78,7 +79,7 @@ flush() fi eval for n in $name $alias\; do \ 'nm=`echo "$n" | sed "s/%/%25/g;s|/|%2F|g"`;' \ - echo '"$ds"' '>$DSV_DIR/dsv-$nm'\; \ + \{ echo '"$ds"'\; echo '"$url"'\; \} '>$DSV_DIR/dsv-$nm'\; \ done name= alias= @@ -157,7 +158,18 @@ search() if [ -d $DSV_DIR ]; then name=`echo "$1" | sed 's/%/%25/g;s|/|%2F|g'` if [ -r "$DSV_DIR/dsv-$name" ]; then - file=`cat "$DSV_DIR/dsv-$name"` + 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"` if [ ! -r "$DSV_DIR/$file" ]; then echo "$1 -> $file: does not exist" 2>&1 exit 1 @@ -179,10 +191,15 @@ search() path=false +show_url=false if [ "$1" = -p ]; then path=true shift fi +if [ "$1" = -u ]; then + show_url=true + shift +fi case "$1" in help|-*) usage;;