]> git.plutz.net Git - shellwiki/blobdiff - searchindex.sh
Merge commit '2e4c276d4c642e43be3d4bb9d7314f87c21746a6'
[shellwiki] / searchindex.sh
index af120f603f26db95b84f095cdadc17c0cec6df25..029f0f4630b108939355c6d5b37434569904fd94 100755 (executable)
@@ -1,6 +1,20 @@
 #!/bin/sh
 
-export _EXEC="${0%/*}/" _DATA="."
+# Copyright 2023 Paul Hänsch
+# 
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+# 
+# THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+# IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+export _EXEC="${_EXEC:-${0%/*}/}" _DATA="${_DATA:-.}"
 verb="" v=0 cmd="" force="" location=""
 
 help() {
@@ -45,14 +59,15 @@ help() {
        Options:
 
        --exec INSTALL_DIR
-           Point to the location of your shellwiki installation. This will
-           default to the path at which the script is called, if it can be
-           determined.
+           Point to the location of your shellwiki installation. Without
+           this optin, the location will be read from the environments
+           variable "\$_EXEC", or will default to the path at which the
+           script is called, if it can be determined.
 
        --data SITE_DIR
            Point to the location of your site installation. I.e. the directory
-           containing your "pages/" and "index/" dir. Defaults to working
-           directory.
+           containing your "pages/" and "index/" dir. Defaults to the
+           environment variable "\$_DATA" or the working directory.
 
        --force
            Add pages to index even if they seem to be indexed already.
@@ -72,6 +87,7 @@ help() {
 while [ $# -gt 0 ]; do case $1 in
   --exec|-e) _EXEC="${2%/}"; shift 2;;
   --data|-d) _DATA="${2%/}"; shift 2;;
+  --location) location="${2}"; shift 2;;
   --verbose|-v) verb=true; shift 1;;
   --force) force=true; shift 1;;
   --help) help 0 2>&1;;
@@ -111,7 +127,7 @@ prune() {
         printf '%i     %s      %f      %i      %i\n' \
                "$date" "$location" "$freq" "$num" "$total"
       elif [ "$verb" ]; then
-        printf "%${v}s\rRemoving \"%s\" from \"%s\"\n" "" "$location" "$word" >&2
+        printf "\rRemoving \"%s\" from \"%s\"\n" "$location" "${word##*/}" >&2
       fi
     done <"${word}.$$" >>"${word}"
     rm -- "${word}.$$"
@@ -134,7 +150,7 @@ index() {
          -o -f "$_DATA/pages/$PATH_INFO/#page.md" \
        -a ! -f "$_DATA/pages/$PATH_INFO/#index.flag" ] 2>&-
   then
-      [ "$verb" ] && printf "%${v}s\r%s\r" "$PATH_INFO" >&2
+      [ "$verb" ] && printf "%${v}s\r%s\r" "" "$PATH_INFO" >&2
       v="${#PATH_INFO}"
       "$_EXEC/parsers/40_indexer.sh" <"$_DATA/pages/$PATH_INFO/#page.md" >/dev/null
     fi