tmove_regression.nim 569 B

1234567891011121314151617181920212223
  1. discard """
  2. output: '''/1/2
  3. /1
  4. /
  5. '''
  6. """"
  7. # bug #22001
  8. import std / [os, strutils]
  9. proc finOp2(path, name: string): (string, File) = # Find & open FIRST `name`
  10. var current = path
  11. while true:
  12. if current.isRootDir: break # <- current=="" => current.isRootDir
  13. current = current.parentDir
  14. let dir = current
  15. echo dir.replace('\\', '/') # Commenting out try/except below hides bug
  16. try: result[0] = dir/name; result[1] = open(result[0]); return
  17. except CatchableError: discard
  18. discard finOp2("/1/2/3", "4") # All same if this->inside a proc