Index: /trunk/src/VBox/Frontends/VBoxShell/vboxshell.py
===================================================================
--- /trunk/src/VBox/Frontends/VBoxShell/vboxshell.py	(revision 30279)
+++ /trunk/src/VBox/Frontends/VBoxShell/vboxshell.py	(revision 30280)
@@ -665,12 +665,18 @@
         return []
     def matches(self,subexp):
-#        m = re.search(r"@(?P<a>\w+)=(?P<v>\w+)", subexp)
+        if subexp == self.type:
+            return True
+        if not subexp.startswith(self.type):
+            return False
+        m = re.search(r"@(?P<a>\w+)=(?P<v>\w+)", subexp)
         matches = False
-#        try:
-#        if m is not None:
-#        else:
-#            print "no match in ",subexp
-#       except:
-
+        try:
+            if m is not None:
+                dict = m.groupdict()
+                attr = dict['a']
+                val  = dict['v']
+                matches = (str(getattr(self.obj, attr)) == val)
+        except:
+            pass
         return matches
     def apply(self, cmd):
@@ -710,6 +716,6 @@
     def __init__(self, parent, obj):
         XPathNode.__init__(self, parent, obj, 'vm')
-    def matches(self,subexp):
-        return subexp=='vm'
+    #def matches(self,subexp):
+    #    return subexp=='vm'
     def enum(self):
         return [XPathNodeHolderNIC(self, self.obj),
@@ -2793,5 +2799,5 @@
 def foreachCmd(ctx, args):
     if len(args) < 3:
-        print "foreach scope command"
+        print "usage: foreach scope command, where scope is XPath-like expression //vms/vm[@CPUCount='2']"
         return 0
 
@@ -2896,5 +2902,5 @@
             'prompt' : ['Control prompt', promptCmd, 0],
             'foreachvm' : ['Perform command for each VM', foreachvmCmd, 0],
-            'foreach' : ['Generic "for each" construction, using XPath-like notation: foreach //vms/vm "print obj.name"', foreachCmd, 0],
+            'foreach' : ['Generic "for each" construction, using XPath-like notation: foreach //vms/vm[@OSTypeId=\'MacOS\'] "print obj.name"', foreachCmd, 0],
             }
 
