def unglobify(glob)
      chars = glob.split("")

      chars = smoosh(chars)

      curlies = 0
      escaping = false
      string = chars.map do |char|
        if escaping
          escaping = false
          char
        else
          case char
            when "**"
              "([^/]+/)*"
            when '*'
              ".*"
            when "?"
              "."
            when "."
              "\."

            when "{"
              curlies += 1
              "("
            when "}"
              if curlies > 0
                curlies -= 1
                ")"
              else
                char
              end
            when ","
              if curlies > 0
                "|"
              else
                char
              end
            when "\\"
              escaping = true
              "\\"
            else
              char
          end
        end
      end

      '(\A|\/)' + string.join + '\Z'
    end
def unglobify(glob)
      chars = glob.split("")

      chars = smoosh(chars)

      curlies = 0
      escaping = false
      string = chars.map do |char|
        if escaping
          escaping = false
          char
        else
          case char
            when "**"
              "([^/]+/)*"
            when '*'
              ".*"
            when "?"
              "."
            when "."
              "\."

            when "{"
              curlies += 1
              "("
            when "}"
              if curlies > 0
                curlies -= 1
                ")"
              else
                char
              end
            when ","
              if curlies > 0
                "|"
              else
                char
              end
            when "\\"
              escaping = true
              "\\"
            else
              char
          end
        end
      end

      '(\A|\/)' + string.join + '\Z'
    end
NOTE: This is actually a glob-to-regex method