Skip to content

Commit

Permalink
Diminish the notion of prelude #84 : get rid of tmp files
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Dec 8, 2021
1 parent 7497161 commit 78ed6ac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
19 changes: 6 additions & 13 deletions makesure.awk
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ BEGIN {
split("",GoalsByName) # name -> private
split("",Code) # name -> body
split("",DefineOverrides) # k -> ""
DefinesFile=""
DefinesCode=""
split("",Dependencies) # name,i -> dep goal
split("",DependenciesLineNo) # name,i -> line no.
split("",DependenciesCnt) # name -> dep cnd
Expand Down Expand Up @@ -143,16 +143,11 @@ function handleDefine() {
$1 = ""
handleDefineLine($0)
}
function handleDefineLine(line, kv,l) {
if (!DefinesFile)
DefinesFile = executeGetLine("mktemp " Tmp "/makesure.XXXXXXXXXX")

function handleDefineLine(line, kv) {
splitKV(line, kv)

if (!(kv[0] in DefineOverrides)) {
addCodeLine(l = line "; export " kv[0])
addCodeLine("echo " quoteArg(l) " >> " DefinesFile)
}
if (!(kv[0] in DefineOverrides))
DefinesCode = addL(DefinesCode, line "; export " kv[0])
}

function handleShell() {
Expand Down Expand Up @@ -404,8 +399,7 @@ body,goalBody,goalBodies,resolvedGoals,exitCode, t0,t1,t2, goalTimed, list) {
}

addLine(definesLine, MyDirScript)
if (DefinesFile)
addLine(definesLine, ". " DefinesFile)
addLine(definesLine, DefinesCode)

for (i = 0; i in GoalNames; i++) {
goalName = GoalNames[i]
Expand Down Expand Up @@ -501,8 +495,7 @@ function currentGoalName() { return isPrelude() ? "" : arrLast(GoalNames) }
function currentLibName() { return arrLast(LibNames) }

function realExit(code) {
if (DefinesFile)
rm(DefinesFile)
# place here any cleanup if needed
exit code
}
function addError(err, n) { if (!n) n=NR; Error=addL(Error, err ":\n" ARGV[1] ":" n ": " Lines[n]) }
Expand Down
6 changes: 0 additions & 6 deletions tests/4_trace.tush
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,10 @@ $ cd "$MYDIR"; ./$MAKESURE -f tests/4_trace.sh
$ cd "$MYDIR"; ./$MAKESURE -f tests/4_trace.sh -x
| goal 'default' ...
| A=aaa
@ + A=aaa
@ + export A
@ + echo ' A=aaa; export A'
@ + echo A=aaa

$ cd "$MYDIR"; ./$MAKESURE -f tests/4_trace.sh --tracing
| goal 'default' ...
| A=aaa
@ + A=aaa
@ + export A
@ + echo ' A=aaa; export A'
@ + echo A=aaa

0 comments on commit 78ed6ac

Please sign in to comment.