1
1
#! /bin/sh
2
2
if command -v gawk > /dev/null; then makesure_awk=' gawk -ltime -v Gawk=1' ; makesure_pre=' ' ; else makesure_awk=awk; makesure_pre=' function gettimeofday(){}' ; fi
3
- exec $makesure_awk -v " Version=0.9.16 " -v " Prog=$0 " " $makesure_pre " '
3
+ exec $makesure_awk -v " Version=0.9.17 " -v " Prog=$0 " " $makesure_pre " '
4
4
BEGIN {
5
5
Shell = "bash"
6
6
SupportedShells["bash"]
@@ -111,7 +111,7 @@ function handleOptions( i) {
111
111
}
112
112
}
113
113
function handleDefine() {
114
- checkPreludeOnly( )
114
+ started("define" )
115
115
$1 = ""
116
116
handleDefineLine($0)
117
117
}
@@ -134,12 +134,10 @@ function handleShell() {
134
134
if (!(Shell in SupportedShells))
135
135
addError("Shell ' \' ' " Shell "' \' ' is not supported")
136
136
}
137
- function adjustOptions() {
138
- if ("silent" in Options)
139
- delete Options["timing"]
137
+ function timingOn() {
138
+ return "timing" in Options && !("silent" in Options)
140
139
}
141
140
function started(mode) {
142
- if (isPrelude()) adjustOptions()
143
141
Mode = mode
144
142
}
145
143
function handleLib( libName) {
@@ -326,7 +324,7 @@ body,goalBody,goalBodies,resolvedGoals,exitCode, t0,t1,t2, goalTimed, list) {
326
324
print quote2(goalName)
327
325
}
328
326
} else {
329
- if ("timing" in Options )
327
+ if (timingOn() )
330
328
t0 = currentTimeMillis()
331
329
addLine(definesLine, MyDirScript)
332
330
addLine(definesLine, DefinesCode)
@@ -362,7 +360,7 @@ body,goalBody,goalBodies,resolvedGoals,exitCode, t0,t1,t2, goalTimed, list) {
362
360
} else {
363
361
for (i = 0; i in resolvedGoals; i++) {
364
362
goalName = resolvedGoals[i]
365
- goalTimed = "timing" in Options && !reachedGoals[goalName] && !emptyGoals[goalName]
363
+ goalTimed = timingOn() && !reachedGoals[goalName] && !emptyGoals[goalName]
366
364
if (goalTimed)
367
365
t1 = t2 ? t2 : currentTimeMillis()
368
366
if (!("silent" in Options))
@@ -377,7 +375,7 @@ body,goalBody,goalBodies,resolvedGoals,exitCode, t0,t1,t2, goalTimed, list) {
377
375
if (exitCode != 0)
378
376
break
379
377
}
380
- if ("timing" in Options )
378
+ if (timingOn() )
381
379
print " total time " renderDuration((t2 ? t2 : currentTimeMillis()) - t0)
382
380
if (exitCode != 0)
383
381
realExit(exitCode)
@@ -398,6 +396,7 @@ function resolveGoalsToRun(result, i, goalName, loop) {
398
396
die("There is a loop in goal dependencies via " loop[1] " -> " loop[2])
399
397
}
400
398
}
399
+ function isCodeAllowed() { return "goal"==Mode || "goal_glob"==Mode || "lib"==Mode }
401
400
function isPrelude() { return "prelude"==Mode }
402
401
function checkPreludeOnly() { if (!isPrelude()) addError("Only use " $1 " in prelude") }
403
402
function checkGoalOnly() { if ("goal" != Mode && "goal_glob" != Mode) addError("Only use " $1 " in @goal") }
@@ -434,9 +433,9 @@ function getMyDir(makesurefilePath) {
434
433
return executeGetLine("cd \"$(dirname " quoteArg(makesurefilePath) ")\";pwd")
435
434
}
436
435
function handleCodeLine(line) {
437
- if (isPrelude () && line !~ /^[ \t]*#/ && trim(line) != "") {
436
+ if (!isCodeAllowed () && line !~ /^[ \t]*#/ && trim(line) != "") {
438
437
if (!ShellInPreludeErrorShown++)
439
- addError("Shell code is not allowed in prelude area ")
438
+ addError("Shell code is not allowed outside goals/libs ")
440
439
} else
441
440
addCodeLine(line)
442
441
}
0 commit comments