Summary Files Commits Branches @commit @diff @stats
path: root / scripts / unarchive
blob: 08688dae8e504960fb09b21b96738949eb1ec5cf (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
#!/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 -s)"

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

__rec_ro() {
	while read -r f
	do
		[ ! -w "$f" ] && continue
		chwrite +w "$f"
		[ -d "$f" ] && __rec_ro "$f"
	done <<FILES
$(ls -A1 "$1")
FILES
}

__rec_ro "$1"