#!/bin/bash global esh := $[readlink -f $BALLS_LIB/../bin/esh] proc render::esh { var view = ""$BALLS_VIEWS/$1"" var compiled = $[esh::compile $view] # source it in a subshell so it gets our variables shell { source "$compiled" } } proc esh::compile { var view = $1 var compiled_fname = ""$view.o"" if [[ ! -f "$compiled_fname" ]] || [[ "$view" -nt "$compiled_fname" ]] { $esh $view > $compiled_fname } echo $compiled_fname } (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:esh) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(readlink)} {(-f)} {($ VSub_Name "$BALLS_LIB") (/../bin/esh)})] ) left_token: spids: [4 11] ) } spids: [3] ) ] spids: [3] ) (FuncDef name: "render::esh" body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:view) op: Equal rhs: {(DQ ($ VSub_Name "$BALLS_VIEWS") (/) ($ VSub_Number "$1"))} spids: [25] ) ] spids: [23] ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:compiled) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [ (C {(esh) (Lit_Other ":") (Lit_Other ":") (compile)} {(DQ ($ VSub_Name "$view"))} ) ] ) left_token: spids: [37 46] ) ) } spids: [35] ) ] spids: [33] ) (Subshell child:(C {(.)} {(DQ ($ VSub_Name "$compiled"))}) spids:[5563]) ] spids: [20] ) spids: [13 19] ) (FuncDef name: "esh::compile" body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:view) op: Equal rhs: {(DQ ($ VSub_Number "$1"))} spids: [80] ) ] spids: [78] ) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:compiled_fname) op: Equal rhs: {(DQ ($ VSub_Name "$view") (.o))} spids: [88] ) ] spids: [86] ) (If arms: [ (if_arm cond: [ (Sentence child: (AndOr children: [ (DBracket expr: (LogicalNot child: (BoolUnary op_id: BoolUnary_f child: {(DQ ($ VSub_Name "$compiled_fname"))} ) ) ) (DBracket expr: (BoolBinary op_id: BoolBinary_nt left: {(DQ ($ VSub_Name "$view"))} right: {(DQ ($ VSub_Name "$compiled_fname"))} ) ) ] op_id: Op_DPipe ) terminator: ) ] action: [ (SimpleCommand words: [{($ VSub_Name "$esh")} {(DQ ($ VSub_Name "$view"))}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(DQ ($ VSub_Name "$compiled_fname"))} spids: [136] ) ] ) ] spids: [-1 127] ) ] spids: [-1 143] ) (C {(echo)} {(DQ ($ VSub_Name "$compiled_fname"))}) ] spids: [75] ) spids: [68 74] ) ] )