delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/03/02/02:23:20

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <40443616.3060108@users.sourceforge.net>
Date: Tue, 02 Mar 2004 02:21:58 -0500
From: Yaakov Selkowitz <yselkowitz AT users DOT sourceforge DOT net>
User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Better way to do this? (bash scripting)
X-Enigmail-Version: 0.83.2.0
X-Enigmail-Supports: pgp-inline, pgp-mime
X-Authentication-Info: Submitted using SMTP AUTH at out005.verizon.net from [68.161.89.3] at Tue, 2 Mar 2004 01:22:05 -0600

--------------030808070603080005040406
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

-----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-----

--------------030808070603080005040406
Content-Type: text/plain;
 name="pkgdoc.sh"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="pkgdoc.sh"

#############################################################################
#
#  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
}

--------------030808070603080005040406
Content-Type: text/plain;
 name="cygdoc.sh"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="cygdoc.sh"

#############################################################################
#
#  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
}


--------------030808070603080005040406
Content-Type: text/plain; charset=us-ascii

--
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/
--------------030808070603080005040406--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019