Oil Dev Tips - oilshell/oil GitHub Wiki

Back to Contributing

Debugging Outside the Spec Test Framework: Pass -p

Example:

test/spec.sh smoke -r 0 -p > c0      # print the test case to a file
_bin/cxx-dbg/osh_eval c0             # run the test case
gdb --args _bin/cxx-dbg/osh_eval c0  # under GDB
                                     # 'r' and 'bt' are the most useful commands

Spec Tests

Soil CI starts at soil/worker.sh

This file defines all the "jobs" and "tasks" you see at http://travis-ci.oilshell.org/github-jobs/

It's the entry point to dozens of shell scripts!

AST and Parse Trees

If you do anything with the AST, use the -n flag to preview it

$ bin/oil -n -c 'proc p(x, @y) { echo hi }'
(command.Proc
  name: <p>
  sig: (proc_sig.Closed untyped:[(UntypedParam name:<Id.Expr_Name x>)] rest:<Id.Expr_Name y>)
  body: (BraceGroup children:[(C {<echo>} {<hi>})])
)

This is really the "LST" -- Lossless Syntax Tree Pattern


If you want to see the Oil expression parse trees, uncomment the if 0 blocks in frontend/parse_lib.py. Those are the entry points into the Oil parser, which uses a pgen2 grammar.

$ bin/oil -n -c 'proc p(x, @y) { echo hi }'
0 oil_proc -
  0 Op_LParen None
  1 proc_params x
    0 proc_param x
      0 Expr_Name x
    1 Arith_Comma None
    2 proc_param @
      0 Expr_At @
      1 Expr_Name y
  2 Op_RParen None
  3 Op_LBrace None
(command.Proc
  name: <p>
  sig: (proc_sig.Closed untyped:[(UntypedParam name:<Id.Expr_Name x>)] rest:<Id.Expr_Name y>)
  body: (BraceGroup children:[(C {<echo>} {<hi>})])
)
⚠️ **GitHub.com Fallback** ⚠️