summaryrefslogtreecommitdiffstats
path: root/bin/undot-paths
diff options
context:
space:
mode:
Diffstat (limited to 'bin/undot-paths')
-rwxr-xr-xbin/undot-paths14
1 files changed, 14 insertions, 0 deletions
diff --git a/bin/undot-paths b/bin/undot-paths
new file mode 100755
index 000000000..2ed86bdec
--- /dev/null
+++ b/bin/undot-paths
@@ -0,0 +1,14 @@
+#! /bin/sh
+# undot_paths : lines path |> lines path
+# Remove all dots (. and ..) from input paths.
+set -euf
+
+sed '
+ :0
+ s://\+:/:g
+ s:/\.\(/\|$\):\1:g
+ s:/[^/]\+/\.\.\(/\|$\):\1:g
+ s:^/\(\.\./\)\+:/:
+ t0
+ s:^$:/:
+'