summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@iiso>2011-09-19 00:20:53 +0200
committertv <tv@iiso>2011-09-19 00:20:53 +0200
commit0a5e023f09d53a4bc784865005003768bf21b877 (patch)
tree2bfb2e55ffa111d5dde0bb20f82fa78820969a5f
parentbea490c675a6f6b5d40c4d6be86161dfc13a5f78 (diff)
//util nextpath: initial commit
-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