code: def glob(dirs, patterns):
      """Returns the list of files matching the given pattern in the
      specified directory.  Both directories and patterns are
      supplied as portable paths. Each pattern should be non-absolute
      path, and can't contain "." or ".." elements. Each slash separated
      element of pattern can contain the following special characters:
      -  '?', which match any character
      -  '*', which matches arbitrary number of characters.
      A file $(d)/e1/e2/e3 (where 'd' is in $(dirs)) matches pattern p1/p2/p3
      if and only if e1 matches p1, e2 matches p2 and so on.
  
      For example:
          [ glob . : *.cpp ]
          [ glob . : */build/Jamfile ]
      """
      #   {
      #       local result ;
      #       if $(patterns:D)
      #       {
      #           # When a pattern has a directory element, we first glob for
      #           # directory, and then glob for file name is the found directories.
      #           for local p in $(patterns)
      #           {
      #               # First glob for directory part.
      #               local globbed-dirs = [ glob $(dirs) : $(p:D) ] ;
      #               result += [ glob $(globbed-dirs) : $(p:D="") ] ;
      #           }
      #       }
      #       else
      #       {
      #           # When a pattern has not directory, we glob directly.
      #           # Take care of special ".." value. The "GLOB" rule simply ignores
      #           # the ".." element (and ".") element in directory listings. This is
      #           # needed so that
      #           #
      #           #    [ glob libs/*/Jamfile ]
      #           #
      #           # don't return
      #           #
      #           #    libs/../Jamfile (which is the same as ./Jamfile)
      #           #
      #           # On the other hand, when ".." is explicitly present in the pattern
      #           # we need to return it.
      #           #
      #           for local dir in $(dirs)
      #           {
      #               for local p in $(patterns)
      #               {
      #                   if $(p) != ".."
      #                   {
      #                       result += [ sequence.transform make
      #                           : [ GLOB [ native $(dir) ] : $(p) ] ] ;
      #                   }
      #                   else
      #                   {
      #                       result += [ path.join $(dir) .. ] ;
      #                   }
      #               }
      #           }
      #       }
      #       return $(result) ;
      #   }
      #
  
      # TODO: (PF) I replaced the code above by this. I think it should work but needs to be tested.
      result = []
      dirs = to_seq(dirs)
      patterns = to_seq(patterns)
  
      splitdirs = []
      for dir in dirs:
          splitdirs += dir.split(os.pathsep)
  
      for dir in splitdirs:
          for pattern in patterns:
              p = os.path.join(dir, pattern)
              import glob
  
              result.extend(glob.glob(p))
      return result
  
imports: import os.path
  from utility import to_seq
  from glob import glob
  from b2.util import bjam_signature
label_desc: Use image node_id 9 for calling a global function with example usage: glob(dirs, patterns) and returns: result