andrewchambers / janetsh

A powerful new shell that uses the janet programming language for both the implementation and repl.

Home Page:https://janet-shell.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Child execution debug printing tracing/hooks

andrewchambers opened this issue · comments

I recently wanted to print out all the commands a script was executing (A C build script) - It was very hard to do so, In bash you do something like:

verbose () {
  echo "$@"
  "$@"
}

verbose cc foo.c ...

In janet I am not sure the right approach, but perhaps a dynamic variable that can be set to control a debug callback then users can define a macro like 'with-verbose'

(with-verbose (do (sh/$ cc ...) (sh/$ cc ...) (sh/$ cc ...)))

An alternative is to integrate with the janet vm trace functions by providing a clear trace point.