-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmount.sh
executable file
·62 lines (52 loc) · 937 Bytes
/
mount.sh
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
58
59
60
61
#!/bin/bash
### mount current directory to specified drive for Cygwin
###
### Usage: mount.sh [DRIVE_LETTER|-d]
if [ $# = 0 ]; then
echo "Usage: $0 [DRIVE_LETTER|-d]
DRIVE_LETTER = mount current directory to the drive.
-d = unmount mounted drive.
* Current mounted drive(s):"
subst
exit
fi
mp=.mounted
case "$1" in
[A-Za-z])
drive=$1:
;;
[A-Za-z]:)
;;
-d)
if [ ! -f $mp ]; then
echo "Not mount."
exit
fi
drive=$(cat $mp)
if [ $(subst | grep -c ^$drive) -gt 0 ]; then
subst $drive /d
echo "Unmounted: $drive"
subst
else
echo "Not mount."
rm -f $mp
fi
exit
;;
*)
echo "Usage: $0 [DRIVE_LETTER|-d]"
echo ""
echo "Error: Unknown drive [$1]"
exit 1
;;
esac
if [ -f $mp -a $(subst | wc -l) -gt 0 ]; then
echo "Error: already mounted."
subst
exit 1
fi
drive=$(echo $drive | tr a-z A-Z)
subst $drive "$(cygpath -aw .)"
echo $drive > $mp
echo "Mounted:"
subst