mostly fixes
[distro-setup] / brc
diff --git a/brc b/brc
index 138fd896b26df6b2ae9361ba75709abd9855fe93..02ad1a67b78073f1cb58f6bac878d3e64def4582 100644 (file)
--- a/brc
+++ b/brc
@@ -2183,6 +2183,23 @@ s/^\Wcapability: (.*)/\1/;Ta;h;b
 "|sort -r
 }
 
+# Run script by copying it to a temporary location first,
+# and changing directory, so we don't have any open
+# directories or files that could cause problems when
+# remounting.
+z() {
+  local tmp
+  tmp=$(type -p "$1")
+  if [[ $tmp ]]; then
+    cd $(mktemp -d)
+    cp -a "$tmp" .
+    shift
+    ./"${tmp##*/}" "$@"
+  else
+    "$@"
+  fi
+}
+
 # * misc stuff