* Added workaround for systems without agrep using awk. 0.3-10
authorMichael Prokop <mika@grml.org>
Sat, 11 Nov 2006 19:12:38 +0000 (20:12 +0100)
committerMichael Prokop <mika@grml.org>
Sat, 11 Nov 2006 19:12:38 +0000 (20:12 +0100)
  * Updated manpage.

debian/changelog
debian/control
grml-tips
grml-tips.1

index ec41127..bc4c81e 100644 (file)
@@ -1,3 +1,10 @@
+grml-tips (0.3-10) unstable; urgency=low
+
+  * Added workaround for systems without agrep using awk.
+  * Updated manpage.
+
+ -- Michael Prokop <mika@grml.org>  Sat, 11 Nov 2006 20:01:41 +0100
+
 grml-tips (0.3-9) unstable; urgency=low
 
   * Updated grml-tips.
 grml-tips (0.3-9) unstable; urgency=low
 
   * Updated grml-tips.
index 9cc2931..2b90ae5 100644 (file)
@@ -7,10 +7,10 @@ Standards-Version: 3.7.2
 
 Package: grml-tips
 Architecture: all
 
 Package: grml-tips
 Architecture: all
-Depends: ${shlibs:Depends}, ${misc:Depends}, agrep
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Suggests: agrep
 Description: search for tips and hints via a keyword
  The provided script grml-tips queries a signature file
 Description: search for tips and hints via a keyword
  The provided script grml-tips queries a signature file
- with agrep for a specific keyword and displays results
- on stdout.
+ for a specific keyword and displays results on stdout.
  .
   Homepage: http://grml.org/
  .
   Homepage: http://grml.org/
index 8d5e91a..7742578 100755 (executable)
--- a/grml-tips
+++ b/grml-tips
@@ -4,25 +4,38 @@
 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
 # Bug-Reports:   see http://grml.org/bugs/
 # License:       This file is licensed under the GPL v2.
 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
 # Bug-Reports:   see http://grml.org/bugs/
 # License:       This file is licensed under the GPL v2.
-# Latest change: Mit Nov 01 12:02:06 CET 2006 [mika]
+# Latest change: Sam Nov 11 20:01:35 CET 2006 [mika]
 ################################################################################
 
 TIPSFILE='/usr/share/grml-tips/grml_tips'
 
 ################################################################################
 
 TIPSFILE='/usr/share/grml-tips/grml_tips'
 
-# another approach:
-# awk 'BEGIN { RS = "-- " } /$1/' $TIPSFILE
+if ! [ -r "$TIPSFILE" ] ; then
+   echo "Error: $TIPSFILE not found. Exiting." >&2
+   exit 1
+fi
 
 
-if [ -r "$TIPSFILE" ] ; then
+if [ -x /usr/bin/agrep ] ; then
+   if [ -n "$1" ] ; then
+     agrep -d "^-- $" -i "$1" $TIPSFILE && echo "" || \
+     ( echo "Sorry, could not find a tip for '$1'. :-(" >&2
+       echo 'If you want to submit a tip please mail it to tips@grml.org - thank you!' >&2
+       exit 1 )
+   else
+     echo "Usage: $0 <keyword>" >&2 ; exit 1
+   fi
+else # workaround solution for systems without agrep :-/
   if [ -n "$1" ] ; then
   if [ -n "$1" ] ; then
-    agrep -d "^-- $" -i "$1" $TIPSFILE && echo "" || \
-    ( echo "Sorry, could not find a tip for '$1'"
-      echo 'If you want to submit a tip please send it to tips@grml.org - thank you!' )
+     TIP=$(awk "BEGIN { RS = \"-- \" } /$1/" "$TIPSFILE")
+     if [ -n "$TIP" ] ; then
+        echo "$TIP"
+     else
+        echo "Sorry, could not find a tip for '$1'. :-(" >&2
+        echo 'If you want to submit a tip please mail it to tips@grml.org - thank you!' >&2
+        exit 1
+     fi
   else
   else
-    echo "Usage: $0 <keyword>" ; exit 1
+    echo "Usage: $0 <keyword>" >&2 ; exit 1
   fi
   fi
-else
-  echo "Error: $TIPSFILE not found. Exiting."
-  exit 1
 fi
 
 ## END OF FILE #################################################################
 fi
 
 ## END OF FILE #################################################################
index 1d86db4..3b21ebf 100644 (file)
@@ -1,4 +1,4 @@
-.TH GRML-TIPS 1 "Dezember 11, 2005"
+.TH GRML-TIPS 1
 .SH NAME
 grml-tips \- query a signature file for a specific keyword and display results
 .SH SYNOPSIS
 .SH NAME
 grml-tips \- query a signature file for a specific keyword and display results
 .SH SYNOPSIS
@@ -10,15 +10,20 @@ This manual page documents briefly the
 command.
 .PP
 .SH Usage example
 command.
 .PP
 .SH Usage example
-.PP
-grml-tips ntfs
-.PP
+.TP
+.BR "grml-tips ntfs"
 Query grml-tips file for tips / hints including keyword "ntfs".
 Query grml-tips file for tips / hints including keyword "ntfs".
+.TP
+.BR "grml-tips ."
+Display all available grml-tips at once.
 .SH FILES
 .PP
 .SH FILES
 .PP
-/etc/grml/grml_tips
+/usr/share/grml-tips/grml_tips
 .PP
 .PP
-Signature file with tips.
+Signature file containing the tips.
+.SH NOTES
+By default grml-tips uses agrep for searching through the signature file.
+If agrep is not available it falls back to use of awk.
 .SH OPTIONS
 This program does not support any options.
 .SH SEE ALSO
 .SH OPTIONS
 This program does not support any options.
 .SH SEE ALSO
@@ -26,5 +31,5 @@ This program does not support any options.
 .SH AUTHOR
 grml-tips was written by Michael Prokop <mika@grml.org>
 .PP
 .SH AUTHOR
 grml-tips was written by Michael Prokop <mika@grml.org>
 .PP
-This manual page was written by Michael Prokop <mika@grml.org>,
+This manual page was written by Michael Prokop <mika@grml.org>
 for the grml project (but may be used by others).
 for the grml project (but may be used by others).