forked from bumper-app/nicad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfixdots
executable file
·57 lines (45 loc) · 904 Bytes
/
fixdots
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
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
# NiCad3 system preparation utility -
# Fix dots in directory names so NiCad can process a system
if [ "$1" == "" ]
then
echo "Usage: fixdots system-source-dir"
exit 99
fi
while [ 1=1 ]
do
# Find all the directories with dots in them, bottom up
find -d "$1" -type d | grep "\." > /tmp/fix$$
if [ ! -s /tmp/fix$$ ]
then
echo "Done."
break
fi
# Quote original versions
ex -s /tmp/fix$$ << EOF
v/^[^ ]* [^\/]*\$/d
1,\$s/.*/\"&"/
w
q
EOF
cp /tmp/fix$$ /tmp/nfix$$
# Make underscore versions
ex -s /tmp/nfix$$ << EOF2
g/\./s//_/g
w
q
EOF2
# Concatenate the two and turn them into move commands
pr -m -t -w 200 /tmp/fix$$ /tmp/nfix$$ > /tmp/cfix$$
ex -s /tmp/cfix$$ << EOF3
1,\$s/^/\/bin\/mv /
1,\$s/[ ][ ][ ]*/ /
w
q
EOF3
# Run the move commands
cat /tmp/cfix$$ | sed -e "s/ */ /"
sh /tmp/cfix$$
done
# Clean up
/bin/rm -f /tmp/fix$$ /tmp/nfix$$ /tmp/cfix$$