[SM-Commit] GIT changes to master sorcery by Jaka Kranjc (4256764a45baeb57ee3054b08287c3aae1cdf034)

Jaka Kranjc scm at sourcemage.org
Tue Dec 23 10:53:44 EST 2008


GIT changes to master sorcery by Jaka Kranjc <lynxlynxlynx at sourcemage.org>:

 ChangeLog                 |    4 ++++
 usr/sbin/gaze             |   25 +++++++++++++++++++++----
 usr/share/man/man1/gaze.1 |    8 ++++++--
 3 files changed, 31 insertions(+), 6 deletions(-)

New commits:
commit 4256764a45baeb57ee3054b08287c3aae1cdf034
Author: Jaka Kranjc <lynxlynxlynx at sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx at sourcemage.org>

    gaze, gaze.1: solidified the gaze from matching and added optional
          regex support (pass -regex)

diff --git a/ChangeLog b/ChangeLog
index 62f33a4..1e50658 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-12-23 Jaka Kranjc <lynxlynxlynx at sourcemage.org>
+	* gaze, gaze.1: solidified the gaze from matching and added optional
+	  regex support (pass -regex)
+
 2008-12-22 Jaka Kranjc <lynxlynxlynx at sourcemage.org>
 	* libmisc: removed the bubble around real_query and reformatted it
 
diff --git a/usr/sbin/gaze b/usr/sbin/gaze
index 85fc397..2fde168 100755
--- a/usr/sbin/gaze
+++ b/usr/sbin/gaze
@@ -19,7 +19,7 @@ Command         Arguments       Description
 -q              <empty>         disables human style output
 
 alien           <empty>         Discovers untracked files.
-from            path/file       Discovers what installed a file.
+from [-regex]   path/file       Discovers what installed a file.
 
 search          "phrase"        Searches for "phrase" in the long and short
                                 spell descriptions and in the spell name.
@@ -663,18 +663,35 @@ function older()  {
 #-----
 ## Find all install logs that mention the given string,
 ## discarding hits that match state files
+## @param mode (-regex to not match literally)
 ## @param Search string
 ## @Stdout grep results
 #-----
 function show_from()  {
+  local mode string
 
-  if [[ -z $1 ]]; then
+  if [[ -z $2 ]]; then
+    string=$1
+  else
+    mode=$1
+    string=$2
+  fi
+
+  if [[ -z $string ]]; then
     error_message "${PROBLEM_COLOR}Missing search string parameter!$DEFAULT_COLOR"
     exit 1
   fi
 
   cd $INSTALL_LOGS
-  find . -printf "%f\n" | xargs grep "`esc_str $1`$" |
+
+  find . -printf "%f\n" |
+  # we use grep -e to protect against patterns starting with a dash
+  if [[ $mode == -regex ]]; then
+    xargs grep -e "$string"
+  else
+    # match the string literally, but only those at the end of the line
+    xargs grep -F -e "$string" | grep -e "$string$"
+  fi |
   seperate_state_files /dev/stdin /dev/stdout /dev/null | sort
 
 }
@@ -2287,7 +2304,7 @@ parse()  {
            alien)  alien                                 ;;
      system-info)  gaze_system_info                      ;;
         activity)  display $ACTIVITY_LOG                 ;;
-            from)  show_from         $2                  ;;
+            from)  shift; show_from "$@"                 ;;
            newer)  newer             $2                  ;;
            older)  older             $2                  ;;
          sources)  sources           $SPELL              ;;
diff --git a/usr/share/man/man1/gaze.1 b/usr/share/man/man1/gaze.1
index 26cc635..554363b 100644
--- a/usr/share/man/man1/gaze.1
+++ b/usr/share/man/man1/gaze.1
@@ -204,10 +204,14 @@ the date must be specified like for
 last_sorcery_update and last_cast may not be used here.
 
 .PP
-.SS from [<path>/]<file>
+.SS from [-regex] [<path>/]<file>
 .IP
-find out what spell has installed
+find out which spell has installed
 .I path/file
+
+Matching is done literally against the end of the path names in the lists
+of installed files. If -regex is passed, the matching is done using basic
+regular expressions against the whole paths in the lists of installed files.
 .PP
 .SS installed [<spell>]
 .IP



More information about the SM-Commit mailing list