From 78ed6ac112288b79968b90dba132f5dca0ded6cc Mon Sep 17 00:00:00 2001 From: xonix Date: Wed, 8 Dec 2021 22:11:53 +0200 Subject: [PATCH] Diminish the notion of prelude #84 : get rid of tmp files --- makesure.awk | 19 ++++++------------- tests/4_trace.tush | 6 ------ 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/makesure.awk b/makesure.awk index 90001e2..169a14b 100755 --- a/makesure.awk +++ b/makesure.awk @@ -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 @@ -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() { @@ -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] @@ -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]) } diff --git a/tests/4_trace.tush b/tests/4_trace.tush index fb01283..8abe626 100644 --- a/tests/4_trace.tush +++ b/tests/4_trace.tush @@ -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