I wonder why the full output of blkid is parsed at all, instead of requesting 
the wanted components separately. It seems it would be much safer and clearer, 
and might be faster as well (though that doesn't really matter).

I'm particularly concerned about possible parsing problems, as this bug shows.

Are the "-s" and "-o" options to blkid not always available?

What about the following patch?

# diff -u src/usbmount/usbmount.orig src/usbmount/usbmount
--- src/usbmount/usbmount.orig    2011-08-08 17:57:49.000000000 +0200
+++ src/usbmount/usbmount    2011-11-23 01:24:40.000000000 +0100
@@ -87,10 +87,10 @@
     # Grab device information from device and "divide it"
     #   FIXME: improvement: implement mounting by label (notice that labels
     #   can contain spaces, which makes things a little bit less comfortable).
-    DEVINFO=$(/sbin/blkid -p $DEVNAME)
-    FSTYPE=$(echo "$DEVINFO" | sed 's/.*[[:blank:]]TYPE="\([^"]*\)".*/\1/g; 
s/[[:blank:]]*//g;')
-    UUID=$(echo "$DEVINFO"   | sed 's/.*[[:blank:]]UUID="\([^"]*\)".*/\1/g; 
s/[[:blank:]]*//g;')
-    USAGE=$(echo "$DEVINFO"  | sed 's/.*[[:blank:]]USAGE="\([^"]*\)".*/\1/g; 
s/[[:blank:]]*//g;')
+    FSTYPE=$(blkid -p -s TYPE -o value $DEVNAME)
+    UUID=$(blkid -p -s UUID -o value $DEVNAME)
+    USAGE=$(blkid -p -s USAGE -o value $DEVNAME)
+    LABEL=$(blkid -p -s LABEL -o value $DEVNAME)

     if ! echo $USAGE | egrep -q "(filesystem|disklabel)"; then
     log info "$DEVNAME does not contain a filesystem or disklabel"





--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to