builtin_fn_debug.d.elv 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #elvdoc:fn src
  2. #
  3. # ```elvish
  4. # src
  5. # ```
  6. #
  7. # Output a map-like value describing the current source being evaluated. The value
  8. # contains the following fields:
  9. #
  10. # - `name`, a unique name of the current source. If the source originates from a
  11. # file, it is the full path of the file.
  12. #
  13. # - `code`, the full body of the current source.
  14. #
  15. # - `is-file`, whether the source originates from a file.
  16. #
  17. # Examples:
  18. #
  19. # ```elvish-transcript
  20. # ~> put (src)[name code is-file]
  21. # ▶ '[tty]'
  22. # ▶ 'put (src)[name code is-file]'
  23. # ▶ $false
  24. # ~> echo 'put (src)[name code is-file]' > show-src.elv
  25. # ~> elvish show-src.elv
  26. # ▶ /home/elf/show-src.elv
  27. # ▶ "put (src)[name code is-file]\n"
  28. # ▶ $true
  29. # ```
  30. #
  31. # Note: this builtin always returns information of the source of the function
  32. # calling `src`. Consider the following example:
  33. #
  34. # ```elvish-transcript
  35. # ~> echo 'fn show { put (src)[name] }' > ~/.elvish/lib/src-fsutil.elv
  36. # ~> use src-util
  37. # ~> src-util:show
  38. # ▶ /home/elf/.elvish/lib/src-fsutil.elv
  39. # ```
  40. #elvdoc:fn -gc
  41. #
  42. # ```elvish
  43. # -gc
  44. # ```
  45. #
  46. # Force the Go garbage collector to run.
  47. #
  48. # This is only useful for debug purposes.
  49. #elvdoc:fn -stack
  50. #
  51. # ```elvish
  52. # -stack
  53. # ```
  54. #
  55. # Print a stack trace.
  56. #
  57. # This is only useful for debug purposes.
  58. #elvdoc:fn -log
  59. #
  60. # ```elvish
  61. # -log $filename
  62. # ```
  63. #
  64. # Direct internal debug logs to the named file.
  65. #
  66. # This is only useful for debug purposes.