-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I hope this isn't considered too far OT, but perhaps someone will find
this useful.

I wrote the attached scripts, which I place in /etc/profile.d/, in order
to get quicker access to the original-package and Cygwin-specific
documentation.  (pkgdoc and cygdoc respectively)

What I wanted to know is:

1) is there a better and/or more precise way of searching for the file?
2) is there a better and/or more precise way of verifying that there's
actually such a file to feed to less, instead of calling find twice?

Thanks,

Yaakov
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFARDYUpiWmPGlmQSMRAu1aAKDdA7+M+wnPOicNdyWjifcVUhNe8wCglX41
sG4Xcs2dK0s6UxN0inASeBY=
=kLLr
-----END PGP SIGNATURE-----
#############################################################################
#
#  Quick command-line access to package documentation files.
#
#  Copyright (C) 2004 by Yaakov Selkowitz.  All Rights Reserved.
#
#  This script is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License as 
#  published by the Free Software Foundation; either version 2 of the 
#  License, or (at your option) any later version.
#
#  This script is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#  General Public License for more details.
#
#############################################################################

version=0.1

if [ ! "${PKGDOC_PATH}" ] ; then \
  PKGDOC_PATH=/usr/doc:/usr/share/doc:/usr/X11R6/doc
  export PKGDOC_PATH
fi


function pkgdoc {

case $1 in 
  -p|--path)
        echo "PKGDOC_PATH=${PKGDOC_PATH}" ; STATUS=$? ;;

  -h|--help)
        echo "Usage: pkgdoc [OPTIONS] PACKAGE FILE

Displays the upstream FILE documentation for specified PACKAGE.

OPTIONS:
  -h, --help            Displays this help and exits.
  -V, --version         Displays version information and exits.
  -p, --path            Displays the current PKGDOC_PATH and exits.
" ; STATUS=$? ;;

  -V|--version)
        echo "pkgdoc $version
Copyright (C) 2004 by Yaakov Selkowitz.  All Rights Reserved.
This script is released under the GNU General Public License.

Bug reports, patches, etc. can be sent to yselkowitz AT users.sourceforge.net.
" ; STATUS=$? ;;

  *)
        for d in `echo ${PKGDOC_PATH} | sed 's%:% %g'` ; do
        for pd in $d/$1-* $d/$1 ; do
          if [ -d $pd ] ; then
          if [ $(find $pd -name $2) ] ; then
            find $pd -name $2 | xargs less
          else
            echo "No $2 documentation was found for the $1 package."
          fi
          fi
        done
        done ; STATUS=$? ;;

esac
}
#############################################################################
#
#  Quick command-line access to Cygwin README files.
#
#  Copyright (C) 2004 by Yaakov Selkowitz.  All Rights Reserved.
#
#  This script is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License as 
#  published by the Free Software Foundation; either version 2 of the 
#  License, or (at your option) any later version.
#
#  This script is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#  General Public License for more details.
#
#############################################################################

version=0.1

if [ ! "${CYGDOC_PATH}" ] ; then \
  CYGDOC_PATH=/usr/doc/Cygwin:/usr/share/doc/Cygwin:/usr/X11R6/doc/Cygwin
  export CYGDOC_PATH
fi


function cygdoc {

case $1 in 
  -p|--path)
        echo "CYGDOC_PATH=${CYGDOC_PATH}" ; STATUS=$? ;;

  -h|--help)
        echo "Usage: cygdoc [OPTIONS] PKG

Displays the Cygwin README documentation for specified package.

OPTIONS:
  -h, --help            Displays this help and exits.
  -V, --version         Displays version information and exits.
  -p, --path            Displays the current CYGDOC_PATH and exits.
" ; STATUS=$? ;;

  -V|--version)
        echo "cygdoc $version
Copyright (C) 2004 by Yaakov Selkowitz.  All Rights Reserved.
This script is released under the GNU General Public License.

Bug reports, patches, etc. can be sent to yselkowitz AT users.sourceforge.net.
" ; STATUS=$? ;;

  *)
        if [ $(find `echo ${CYGDOC_PATH} | sed 's%:% %g'` -name $1-*.README -o -name 
$1.README) ] ; then
          find `echo ${CYGDOC_PATH} | sed 's%:% %g'` -name $1-*.README -o \
            -name $1.README | xargs less
        else
          echo "No Cygwin README file was found for the $1 package."
        fi ; STATUS=$? ;;

esac
}

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Reply via email to