Misc updates to header-symbol-search and handy_funcs
authorSteve Youngs <steve@steveyoungs.com>
Sun, 24 Jan 2021 05:32:04 +0000 (15:32 +1000)
committerSteve Youngs <steve@steveyoungs.com>
Sun, 24 Jan 2021 05:32:04 +0000 (15:32 +1000)
header-symbol-search had broken, grep's '--mmap' option no longer
exists.  This patch fixes that, as well as getting rid of an obnoxious
loop.

In handy_funcs, the vtar and xtar functions have been replaced with
far simpler shell aliases.  See:

  vtar is aliased to 'less'
  xtar is aliased to 'tar xf'

* usr/bin/header-symbol-search (all_headers): Removed.
Forget slow-as-fuck looping, just recurse.

* etc/pkgusr/handy_funcs (xtar,vtar): Replaced with simpler
aliases.

Signed-off-by: Steve Youngs <steve@steveyoungs.com>
etc/pkgusr/handy_funcs
usr/bin/header-symbol-search

index 2158024..d22e388 100644 (file)
@@ -112,70 +112,6 @@ gpkg()
     sed -n ${top},${bot}p ${HOME}/.project|less
 }
 
-xtar()
-{
-    local opts
-    local type
-    local fname=$1
-
-    if [ -z "${fname}" ]; then
-       echo No filename specified >&2
-       return 1
-    fi
-
-    type=$(file ${fname}|cut -d' ' -f2)
-
-    case $type in
-       (tar)    opts=xf ;;
-       (gzip)   opts=zxf ;;
-       (bzip2)  opts=jxf ;;
-       (xz|XZ)  opts=Jxf ;;
-       (*)
-       # try lzma
-       if lzmainfo ${fname} &>/dev/null; then
-           opts="--lzma -xf"
-       else
-           printf "Unknown file type: %s\n" $type >&2
-           return 2
-       fi
-       ;;
-    esac
-
-    tar ${opts} ${fname}
-}
-
-vtar()
-{
-    local opts
-    local type
-    local fname=$1
-
-    if [ -z "${fname}" ]; then
-       echo No filename specified >&2
-       return 1
-    fi
-
-    type=$(file ${fname}|cut -d' ' -f2)
-
-    case $type in
-       (tar)    opts=tvvvf ;;
-       (gzip)   opts=ztvvvf ;;
-       (bzip2)  opts=jtvvvf ;;
-       (xz|XZ)  opts=Jtvvvf ;;
-       (*)
-        # lzma.  Here because lzmainfo is too stupid
-       if lzmainfo ${fname} &>/dev/null; then
-           opts="--lzma -tvvvf"
-       else
-           printf "Unknown file type: %s\n" $type >&2
-           return 2
-       fi
-       ;;
-    esac
-
-    tar ${opts} ${fname}|less
-}
-
 ## Check if there is a newer build script, maybe update.
 #  NOTE: Updating needs SXEmacs.  It'll work in XEmacs and Emacs too,
 #  but you'll need to change build-update() accordingly.
@@ -248,6 +184,8 @@ alias ebp='vi -a ${HOME}/{build,.project}'
 alias deps='grep --colour "Deps: " ${HOME}/.project'
 alias listp='pinky -l $(whoami)|less'
 alias patches='find ${SLACKPKG}/**/$(whoami)|grep -E "(diff|patch)"'
+alias vtar=less
+alias xtar='tar xf'
 
 H-pkg()
 {
@@ -279,22 +217,20 @@ Logs:
 
 Package Notes/Content:
 
-        ipkg            Displays the \`Install Notes'. (alias: ipkg)
-        gpkg            Displays the \`General Notes'. (alias: gpkg)
+        ipkg            Displays the \`Install Notes'.
+        gpkg            Displays the \`General Notes'.
         listp           Displays the entire package info (piped through less(1))
         srepo           Display the package's source repo location.
        rawrepo         Output just the repo URL (to use with lynx, curl, etc)
-        trepo           Display the type of repo (tla, git, svn, mercurial etc)
+        trepo           Display the type of repo (git, svn, mercurial, tla etc)
         web             Display the package's homepage URL.
        rawweb          Output just the web URL (to use with lynx etc)
         deps            Display the package's dependencies
 
 Tarball Handling:
 
-        xtar [TARBALL]  Extract TARBALL, automatically choosing the appropriate
-                        tar(1) options.
-        vtar [TARBALL]  List the contents of TARBALL, automatically choosing 
-                        appropriate options and piping through less(1).
+        xtar [TARBALL]  Extract TARBALL
+        vtar [TARBALL]  List the contents of TARBALL
 
 Build Scripts:
 
index 6a22bf8..4ebf4bc 100755 (executable)
@@ -1,11 +1,11 @@
 #!/bin/bash
 
-# Copyright (C) 2008 - 2014 Steve Youngs
+# Copyright (C) 2008 - 2021 Steve Youngs
 
 # Author:     Steve Youngs <steve@sxemacs.org>
 # Maintainer: Steve Youngs <steve@sxemacs.org>
 # Created:    <2008-03-10>
-# Time-stamp: <Monday Mar  3, 2014 17:24:16 steve>
+# Time-stamp: <Sunday Jan 24, 2021 15:30:21 steve>
 # Homepage:   N/A
 # Keywords:   utils package-management
 
@@ -66,22 +66,18 @@ fi
 header_dirs=(/usr/include /usr/X11R6/include)
 
 ## bastard header directories...
-#header_dirs=(\
-#      /usr/include \
-#      /usr/X11R6/include \
-#      /opt/jdk/include \
-#      /opt/qt/include \
-#      /opt/kde/include)
+# header_dirs=(\
+#      /usr/include \
+#      /usr/X11R6/include \
+#      /opt/jdk/include \
+#      /opt/qt/include \
+#      /opt/kde/include)
 
 sym=${1}
 
-all_headers=$(find -H -L ${header_dirs[*]} -type f -name "*.h" -print)
-
 ### FIXME: This is totally brain dead, it'll match on shit you don't
 #          want like comments.
 #    A possible solution might be to use etags in some way.
-for header in ${all_headers} ; do
-    grep -E -l --mmap --colour ${sym} ${header} 2>/dev/null
-done
+grep -Erlm1 --colour ${sym} ${header_dirs[*]} 2>/dev/null
 
 ## header-symbol-search ends here