summaryrefslogtreecommitdiffstats
path: root/util/bin/nextpath
diff options
context:
space:
mode:
Diffstat (limited to 'util/bin/nextpath')
-rwxr-xr-xutil/bin/nextpath12
1 files changed, 12 insertions, 0 deletions
diff --git a/util/bin/nextpath b/util/bin/nextpath
new file mode 100755
index 00000000..fbffa894
--- /dev/null
+++ b/util/bin/nextpath
@@ -0,0 +1,12 @@
+#! /bin/sh
+#
+# nextpath [component...]
+#
+# echo $PATH with the components stripped
+#
+set -euf
+
+pattern="^\\(${1-}$(shift;for i; do echo -n "\\|$i"; done)\\)$"
+
+echo -n "$(echo -n "$PATH" | tr : '\n' | grep -v "$pattern")" | tr '\n' :
+echo