|
Revision 7647, 1.4 kB
(checked in by cristy, 14 months ago)
|
|
|
-
Property svn:executable set to
*
|
| Line | |
|---|
| 1 | #!/bin/sh |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | arg="$1" |
|---|
| 14 | escapes=0 |
|---|
| 15 | if test -n "$2" |
|---|
| 16 | then |
|---|
| 17 | escapes="$2" |
|---|
| 18 | fi |
|---|
| 19 | if test $escapes -gt 3 |
|---|
| 20 | then |
|---|
| 21 | echo "$0: escape level must in range 0 - 3" |
|---|
| 22 | exit 1 |
|---|
| 23 | fi |
|---|
| 24 | result='' |
|---|
| 25 | length=0 |
|---|
| 26 | max_length=0 |
|---|
| 27 | mount | sed -e 's:\\:/:g' | ( |
|---|
| 28 | IFS="\n" |
|---|
| 29 | while read mount_entry |
|---|
| 30 | do |
|---|
| 31 | win_mount_path=`echo "$mount_entry" | sed -e 's: .*::g'` |
|---|
| 32 | unix_mount_path=`echo "$mount_entry" | sed -e 's:.* on ::;s: type .*::'` |
|---|
| 33 | temp=`echo "$arg" | sed -e "s!^$unix_mount_path!$win_mount_path!"` |
|---|
| 34 | if test "$temp" != "$arg" |
|---|
| 35 | then |
|---|
| 36 | candidate="$temp" |
|---|
| 37 | length=${ |
|---|
| 38 | if test $length -gt $max_length |
|---|
| 39 | then |
|---|
| 40 | result=$candidate |
|---|
| 41 | max_length=$length |
|---|
| 42 | fi |
|---|
| 43 | fi |
|---|
| 44 | done |
|---|
| 45 | if test -z "$result" |
|---|
| 46 | then |
|---|
| 47 | echo "$0: path \"$arg\" is not mounted" |
|---|
| 48 | exit 1 |
|---|
| 49 | fi |
|---|
| 50 | case $escapes in |
|---|
| 51 | 0) |
|---|
| 52 | echo "$result" | sed -e 's:/:\\:g' |
|---|
| 53 | ;; |
|---|
| 54 | 1) |
|---|
| 55 | echo "$result" | sed -e 's:/:\\\\:g' |
|---|
| 56 | ;; |
|---|
| 57 | 2) |
|---|
| 58 | echo "$result" | sed -e 's:/:\\\\\\\\:g' |
|---|
| 59 | ;; |
|---|
| 60 | 3) |
|---|
| 61 | echo "$result" | sed -e 's:/:\\\\\\\\\\\\\\\\:g' |
|---|
| 62 | ;; |
|---|
| 63 | esac |
|---|
| 64 | exit 0; |
|---|
| 65 | ) |
|---|