Skip to content

Commit

Permalink
Fix temp file bug
Browse files Browse the repository at this point in the history
Removed temp file altogether
  • Loading branch information
pcrockett committed Nov 21, 2021
1 parent 81c56e5 commit ae2480d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
13 changes: 4 additions & 9 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 @@ -142,14 +142,11 @@ function handleDefine() {
handleDefineLine($0)
}
function handleDefineLine(line, kv,l) {
if (!DefinesFile)
DefinesFile = executeGetLine("mktemp " Tmp "/makesure.XXXXXXXXXX")

splitKV(line, kv)

if (!(kv[0] in DefineOverrides)) {
handleCodeLine(l = line "; export " kv[0])
handleCodeLine("echo " quoteArg(l) " >> " DefinesFile)
DefinesCode = DefinesCode "\n" line "; export " kv[0]
}
}

Expand Down Expand Up @@ -402,8 +399,8 @@ body,goalBody,goalBodies,resolvedGoals,exitCode, t0,t1,t2, goalTimed, list) {
}

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

for (i = 0; i in GoalNames; i++) {
goalName = GoalNames[i]
Expand Down Expand Up @@ -502,8 +499,6 @@ function currentLibName() { return arrLast(LibNames) }

function realExit(code) {
Died = 1
if (DefinesFile)
rm(DefinesFile)
exit code
}
function addError(err, n) { if (!n) n=NR; Error=addL(Error, err ":\n" ARGV[1] ":" n ": " Lines[n]) }
Expand Down
7 changes: 2 additions & 5 deletions tests/15_lib.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@

# TODO found one other bug, but let's fix it separately
#@define HELLO="Hello"
@define HELLO="Hello"

@lib
f1 () {
# TODO found one other bug, but let's fix it separately
#echo "$HELLO $1"
echo "Hello $1"
echo "$HELLO $1"
}

@goal g1
Expand Down
2 changes: 0 additions & 2 deletions tests/4_trace.tush
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ $ cd "$MYDIR"; ./$MAKESURE -f tests/4_trace.sh -x
| 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 ae2480d

Please sign in to comment.