![]() |
|||||||||||
|
#12
|
|||
|
|||
|
(As before, I don't have any AFP volumes to test this with, but I did test the "space, single-quotes, and/or parentheses in the volume name" aspect with disk images.)
Quote:
I worked up this hack to handle volume names with spaces (and single quotes, too): Code:
mount | grep ^afp_ \ | sed -E -e 's/^.* on //;s/( \([^()]*\))?$//;'"s/'/'\\\\''/g;s/^/'/;s/\$/'/" \ | xargs umount -f
OK, here it is with Perl, to better handle the problem with " on " in volume names: Code:
mount | grep ^afp_ \ | perl -pe 's/.*? on //;s/( \([^)]*\))?$//;'"s/'/'\\\\''/;s/^/'/;s/\$/'/" \ | xargs umount -f This Perl version still has the problem with parentheses in the parenthesized expression that follows the volume name. Is it safer to assume that users won't put parentheses in their volume names, or that Apple won't put them in the mount options list? If both are possible (and they definitely and probably are, respectively) then I don't see a clear way to distinguish between the volume name and the mount options (unless you assume the mount options will always have balanced parentheses, which can't be matched by regular expressions, so it would take a fancier approach anyway). Oh, and both of these scripts still have a problem if the string " on " appears in the device part of the mount command's output. I haven't seen that happen, but I wouldn't rule it out (maybe AFP or NFS mounts already do that, I don't have anything to test with, but I'd guess AFP uses a URI-like device name and NFS uses the traditional machine:export device name). This is another intractable problem that stems from trying to parse the undelimited format of the output from the mount command. There has to be a better way to get at all this information (either through some delimited output, or an API: mount does it, Disk Utility does it, something else should be able to also), but it may be beyond what is reasonable in a simple little script. |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Smart Update copying files that haven't been changed? | salparadi | General | 3 | 11-05-2006 11:40 AM |
| Copying newer files across volumes. | chip | General | 1 | 08-09-2006 08:07 PM |
| Long Hang While Copying | BackerUpper | General | 4 | 06-12-2006 08:26 AM |
| SuperDuper! Erasing Audio Files? | Emerson | General | 3 | 06-22-2005 01:41 PM |
| Smart update copying all files each time | fabius | General | 15 | 05-29-2005 09:29 PM |