minor bug fix
[distro-setup] / brc
diff --git a/brc b/brc
index ad1a0781c291eb0652cd1b3a04ff50d067b34598..37e09a0c13399224b748366482fc84b22f7a96ed 100644 (file)
--- a/brc
+++ b/brc
@@ -198,8 +198,10 @@ if [[ -s /usr/share/wcd/wcd-include.sh ]]; then
   source /usr/share/wcd/wcd-include.sh
 fi
 
-if [[ -s ~/.iank/ll-function ]]; then
-  # shellcheck source=.iank/ll-function
+if [[ -s /a/bin/small-misc-bash/ll-function ]]; then
+  # shellcheck source=/a/bin/small-misc-bash/ll-function
+  source /a/bin/small-misc-bash/ll-function
+elif [[ -s ~/.iank/ll-function ]]; then
   source ~/.iank/ll-function
 fi
 
@@ -410,6 +412,39 @@ despace() {
   done
 }
 
+dig() {
+  command dig +nostats +nocmd "$@"
+}
+# Output with sections sorted, and removal of query id, so 2 dig outputs can be diffed.
+digsort() {
+  local sec
+  sec=
+  dig +nordflag "$@" | sed -r 's/^(;; ->>HEADER<<-.*), id: .*/\1/' | while read -r l; do
+    if [[ $l == [^\;]* ]]; then
+      sec+="$l"$'\n'
+    else
+      if [[ $sec ]]; then
+        printf "%s" "$sec" | sort
+        sec=
+      fi
+      printf "%s\n" "$l"
+    fi
+  done
+}
+# compare digs to the 2 servers
+# usage: digdiff @server1 @server2 DIG_ARGS
+# note: only the soa master nameserver will respond with
+# ra "recursive answer" flag. That difference is meaningless afaik.
+digdiff() {
+  local s1 s2
+  s1=$1
+  shift
+  s2=$1
+  shift
+  digsort $s1 "$@" | tee /tmp/digdiff
+  diff -u /tmp/digdiff <(digsort $s2 "$@")
+}
+
 dt() {
   date "+%A, %B %d, %r" "$@"
 }
@@ -422,10 +457,25 @@ dus() { # du, sorted, default arg of
 
 e() { echo "$@"; }
 
-# echo var. print var including escapes, etc
+# echo args
+ea() {
+  if (( ! $# )); then
+    echo no args
+  fi
+  for arg; do
+    printf "%qEOL\n" "${arg}"
+    printf "%s" "${arg}" |& hexdump -C
+  done
+}
+# echo vars. print var including escapes, etc
 ev() {
-  printf "%qEOL\n" "${!1}"
-  printf "%s" "${!1}" |& hexdump -C
+  if (( ! $# )); then
+    echo no args
+  fi
+  for arg; do
+    printf "%qEOL\n" "${!arg}"
+    printf "%s" "${!arg}" |& hexdump -C
+  done
 }
 
 
@@ -441,6 +491,12 @@ etail() {
 eless() {
   less /var/log/exim4/mainlog
 }
+eqcat() {
+  exiqgrep -i | while read i; do
+    exim -Mvh $i; hr; exim -Mvb $i; hr;
+    exigrep $i /var/log/exim4/mainlog; hr
+  done
+}
 
 
 # shellcheck disable=SC2032
@@ -746,6 +802,7 @@ nopanic() {
 }
 
 p8() { ping 8.8.8.8; }
+p6() { ping6 2001:4860:4860::8888; }
 
 pkx() { # package extract
   local pkg cached tmp f