summaryrefslogtreecommitdiff
path: root/sisc
diff options
context:
space:
mode:
authorEthan Morgan <ethan@gweithio.com>2026-02-13 14:58:57 +0000
committerEthan Morgan <ethan@gweithio.com>2026-02-13 14:58:57 +0000
commitb2318bae725de4055c0466e3f1858f51b22e37fe (patch)
tree44645ccbe2312faffb694202919026c414b626cb /sisc
add scriptsHEADmaster
Diffstat (limited to 'sisc')
-rwxr-xr-xsisc45
1 files changed, 45 insertions, 0 deletions
diff --git a/sisc b/sisc
new file mode 100755
index 0000000..137bd48
--- /dev/null
+++ b/sisc
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+# Some weird script to find a word
+
+if [ $# -lt 1 ]; then
+ echo "Usage: $0 <search_word> [search_directory] [ignored_dir1] [ignored_dir2] ..." >&2
+ exit 1
+fi
+
+WORD="$1"
+shift
+
+DIR="${1:-.}"
+shift
+
+if [ ! -d "$DIR" ]; then
+ echo "Error: Directory '$DIR' does not exist." >&2
+ exit 1
+fi
+
+IGNORED_DIRS=""
+while [ $# -gt 0 ]; do
+ IGNORED_DIR="$1"
+ # Construct prune conditions
+ if [ -z "$IGNORED_DIRS" ]; then
+ IGNORED_DIRS="-path \"$DIR/$IGNORED_DIR\" -prune"
+ else
+ IGNORED_DIRS="$IGNORED_DIRS -o -path \"$DIR/$IGNORED_DIR\" -prune"
+ fi
+ shift
+done
+
+if [ -n "$IGNORED_DIRS" ]; then
+ FIND_COMMAND="find \"$DIR\" $IGNORED_DIRS -o -type f -print"
+else
+ FIND_COMMAND="find \"$DIR\" -type f"
+fi
+
+eval "$FIND_COMMAND" | while read -r file; do
+ if grep -q "$WORD" "$file" 2>/dev/null; then
+ grep -n "$WORD" "$file" 2>/dev/null | while IFS=: read -r linenum line; do
+ printf "%s:%d - %s\n" "$file" "$linenum" "$(echo "$line" | sed 's/^ *//')"
+ done
+ fi
+done