bit of a bug in initial check-in; was not passing filename to first grep.
[feisty_meow.git] / scripts / core / functions.sh
index c72a80aa4927b6a49f662dd37ad63bf974ec2796..3024f8200ece981d94c4eb1fd52eaeab8400d18d 100644 (file)
@@ -77,7 +77,6 @@ if [ -z "$skip_all" ]; then
   # locates a process given a search pattern to match in the process list.
   function psfind() {
     local -a patterns=("${@}")
-    mkdir $TEST_TEMP/grid_logs &>/dev/null
     local PID_DUMP="$(mktemp "$TMP/zz_pidlist.XXXXXX")"
     local -a PIDS_SOUGHT
     if [ "$OS" == "Windows_NT" ]; then
@@ -99,9 +98,10 @@ if [ -z "$skip_all" ]; then
       # we 'type' the file to get rid of the unicode result from wmic.
       cmd $flag type "$tmppid" >$PID_DUMP
       \rm "$tmppid"
-      local CR='
-'  # embedded carriage return.
-      local appropriate_pattern="s/^.*  *\([0-9][0-9]*\)[ $CR]*\$/\1/p"
+#      local CR='
+#'  # embedded carriage return.
+#      local appropriate_pattern="s/^.*  *\([0-9][0-9]*\)[ $CR]*\$/\1/p"
+      local appropriate_pattern="s/^.*  *\([0-9][0-9]*\) *\$/\1/p"
       for i in "${patterns[@]}"; do
         PIDS_SOUGHT+=($(cat $PID_DUMP \
           | grep -i "$i" \
@@ -122,11 +122,10 @@ if [ -z "$skip_all" ]; then
       done
     fi
     if [ ${#PIDS_SOUGHT[*]} -ne 0 ]; then
-      local TMPFUD=$(mktemp $TMP/junkpids.XXXXXX)
-      printf -- '%s\n' ${PIDS_SOUGHT[@]} | sort | uniq >$TMPFUD
-      PIDS_SOUGHT=$(cat $TMPFUD)
+      local PIDS_SOUGHT2=$(printf -- '%s\n' ${PIDS_SOUGHT[@]} | sort | uniq)
+      PIDS_SOUGHT=()
+      PIDS_SOUGHT=${PIDS_SOUGHT2[*]}
       echo ${PIDS_SOUGHT[*]}
-#rm $TMPFUD
     fi
     /bin/rm $PID_DUMP
   }
@@ -138,13 +137,13 @@ if [ -z "$skip_all" ]; then
       echo "psa finds processes by pattern, but there was no pattern on the command line."
       return 1
     fi
-    p=$(psfind "$1")
+    p=$(psfind "${@}")
     if [ -z "$p" ]; then
       # no matches.
       return 0
     fi
     echo ""
-    echo "Processes containing \"$1\"..."
+    echo "Processes matching ${@}..."
     echo ""
     if [ -n "$IS_DARWIN" ]; then
       unset fuzil_sentinel