blob: 97c198240818e05a767af5d66354fa2fc011a2b3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#!/bin/bash
after () { test -z "${2##*$1*}" && echo -n "${2#*$1}"; }
res="$(vsvs-locate "$2" || exit 1)"
path="${res%% *}"
vsvspath=$(after " " "$res")
if test -f "$path"
then
lockfile="$base/proc/$proc/lock/"
if test "${path::1}" == "."
then lockfile="$lockfile$base$path"
else lockfile="$lockfile$path"
fi
mkdir -p -- "${lockfile%/*}"
echo $proc > $lockfile
lockpath="$path.lock"
ln $lockfile $lockpath || exit 1 # Error, cannot lock
data="$(cat $path)"
rm $lockpath
rm $lockfile
until test -z "$vsvspath"
do
data="$(echo -n "$data" | vsvs-parse "
if test \"\$key\" == \"${vsvspath%%/*}\"
then
echo \"\$value\"
exit 0
fi")"
vsvspath=$(after / "$vsvspath")
done
echo -n "$data" | vsvs-parse "$1"
else
for key in `ls -a $path`
do
test "$key" == "." || test "$key" == ".." && continue
if test -f "$path/$key"
then value=$(cat "$path/$key")
else
savedpath=$(pwd)
cd "$path/$key"
value=$(vsvs-archive)
cd "$savedpath"
fi
eval "$1"
done
fi
|