Summary Files Commits Branches @commit @diff @stats
path: root / scripts / unarchive
blob: f81086535e5dbe5776a224ec3a3d80c17c4bcd7d (plain) (blame)
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
#!/bin/bash

if [ -z "$1" ]
then
	printf 'Repository: '
	read
	set "$REPLY"
fi

set "$(echo -e "a\n$1/\n.\n1s|\.\+/||g\n1s|/\+|/|g\n1p\nQ" | ed -sqr | tail -1)"

if [ ! -d "$1" ]
then
	echo 'Not a directory!'
	exit 1
fi

set "${1%%/objects/*}"
set "${1%%/refs/*}"

__rec_ro() {
	while read -r f
	do
		if [ -n "$f" ]
		then
			chwrite +w "$1/$f"
			if [ -d "$1/$f" ]
			then
				__rec_ro "$1/$f"
			fi
		fi
	done <<FILES
$(ls -A1 "$1")
FILES
}

chwrite +w "$1"
__rec_ro "$1"