From ae3ad126181f6f974941190848ed9532edbfc6c5 Mon Sep 17 00:00:00 2001 From: Aleksey Veresov Date: Sun, 6 Dec 2020 22:02:01 +0300 Subject: . --- vsvs-archive | 1 - vsvs-locate | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 vsvs-locate diff --git a/vsvs-archive b/vsvs-archive index aea12ef..e328157 100644 --- a/vsvs-archive +++ b/vsvs-archive @@ -1,6 +1,5 @@ #!/bin/bash # Current directory will be represented as VSVS archive in output. -# The directory itself should be locked. for e in `ls -a` do test "$e" == "." || test "$e" == ".." && continue diff --git a/vsvs-locate b/vsvs-locate new file mode 100644 index 0000000..009eccc --- /dev/null +++ b/vsvs-locate @@ -0,0 +1,14 @@ +#!/bin/bash +# Tear $1 into path to file (or directory) and in file, +# if no such file exit with error. +after () { test -z "${2##*$1*}" && echo -n "${2#*$1}"; } +test "${1::1}" == "/" && path=$base || path="." +lastpath=$1 +until test -n "$lastpath" || test -f "$path" +do + path="$path/${lastpath%%/*}" + lastpath=$(after / "$lastpath") + test -e "$path" || exit 1 +done +echo "$path" +echo "$lastpath" -- cgit v1.2.3