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.22 " -v " Prog=$0 " " $makesure_pre " '
3
+ exec $makesure_awk -v " Version=0.9.23 " -v " Prog=$0 " " $makesure_pre " '
4
4
BEGIN {
5
5
Shell="bash"
6
6
SupportedShells["bash"]
@@ -103,7 +103,7 @@ function handleDefine(){
103
103
if(NF!=3){
104
104
addError("Invalid @define syntax, should be @define VAR_NAME ' \' ' value' \' ' ")
105
105
return}
106
- if($2 !~ /^[A-Za-z_][A-Za-z0-9_]*$/){
106
+ if($2!~ /^[A-Za-z_][A-Za-z0-9_]*$/){
107
107
addError("Wrong variable name: ' \' ' "$2"' \' ' ")
108
108
return}
109
109
if(!($2 in DefineOverrides))
@@ -143,7 +143,7 @@ function handleGoal(i,goalName){
143
143
GoalParams[goalName,GoalParamsCnt[goalName]++]=validateParamName($i)
144
144
}else if(NF>2)addError("nothing allowed after goal name")}
145
145
function validateParamName(p){
146
- if(p !~ /^[A-Z_][A-Z0-9_]*$/)addError("@param name should match /^[A-Z_][A-Z0-9_]*$/: ' \' ' "p"' \' ' ")
146
+ if(p!~ /^[A-Z_][A-Z0-9_]*$/)addError("@param name should match /^[A-Z_][A-Z0-9_]*$/: ' \' ' "p"' \' ' ")
147
147
return p}
148
148
function registerGoal(priv,goalName){
149
149
if(""==goalName||"@params"==goalName)
@@ -180,7 +180,7 @@ function handleGoalGlob(goalName,globAllGoal,globSingle,priv,i,pattern,nfMax,gi,
180
180
}else
181
181
pattern=$(nfMax=4)
182
182
if(NF>nfMax&&"@params"!=$(nfMax+1))
183
- addError("nothing or @params allowed after glob pattern")
183
+ addError("nothing or @params allowed after glob pattern")
184
184
else if(pattern=="")
185
185
addError("absent glob pattern")
186
186
else {
@@ -389,7 +389,7 @@ function shellExec(script,comment,res){
389
389
function getMyDir(makesurefilePath){
390
390
return executeGetLine("cd \"$(dirname "quoteArg(makesurefilePath)")\";pwd")}
391
391
function handleCodeLine(line){
392
- if(!isCodeAllowed()&&line !~ /^[ \t]*#/&&trim(line)!=""){
392
+ if(!isCodeAllowed()&&line!~ /^[ \t]*#/&&trim(line)!=""){
393
393
if(!ShellInPreludeErrorShown++)
394
394
addError("Shell code is not allowed outside goals/libs")
395
395
}else
@@ -454,7 +454,7 @@ function instantiate(goal,args,newArgs,i,j,depArg,depArgType,dep,goalNameInstant
454
454
copyKey(goal,goalNameInstantiated,ReachedIf)
455
455
copyKey(goal,goalNameInstantiated,GoalToLib)
456
456
for(i in args)
457
- argsCode=addL(argsCode,i"="quoteArg(args[i]))
457
+ argsCode=addL(argsCode,i"="quoteArg(args[i])";export "i )
458
458
CodePre[goalNameInstantiated]=addL(CodePre[goalNameInstantiated],argsCode)
459
459
if(goalNameInstantiated in ReachedIf)
460
460
ReachedIf[goalNameInstantiated]=argsCode"\n"ReachedIf[goalNameInstantiated]}
@@ -601,7 +601,7 @@ function parseCli_2(line,vars,vars2,res,pos,c,c1,isDoll,q,var,inDef,defVal,val,w
601
601
return"unterminated argument"
602
602
if(!inDef&&":"==c&&"-"==substr(line,pos+1,1)){
603
603
inDef=1
604
- c=substr(line,pos += 2,1)}
604
+ c=substr(line,pos+= 2,1)}
605
605
if(inDef){
606
606
if("}"==c)
607
607
break
@@ -613,7 +613,7 @@ function parseCli_2(line,vars,vars2,res,pos,c,c1,isDoll,q,var,inDef,defVal,val,w
613
613
}else
614
614
for(;(c=substr(line,pos+1,1))~/[_A-Za-z0-9]/;pos++)
615
615
var=var c
616
- if(var !~ /^[_A-Za-z][_A-Za-z0-9]*$/)
616
+ if(var!~ /^[_A-Za-z][_A-Za-z0-9]*$/)
617
617
return"wrong var: ' \' ' "var"' \' ' "
618
618
w=(w)((val=var in vars?vars[var]:var in vars2?vars2[var]:ENVIRON[var])!=""?val:defVal)
619
619
continue}
@@ -626,7 +626,7 @@ function parseCli_2(line,vars,vars2,res,pos,c,c1,isDoll,q,var,inDef,defVal,val,w
626
626
w=c
627
627
while((c=substr(line,++pos,1))!=""&&c!=" "&&c!="\t"){
628
628
w=w c}
629
- if(w !~ /^[_A-Za-z0-9@.]+$/)
629
+ if(w!~ /^[- _A-Za-z0-9@.]+$/)
630
630
return"wrong unquoted: ' \' ' "w"' \' ' "
631
631
res[i=+res[-7]++,"quote"]="u"
632
632
res[i]=w}}}}
@@ -639,7 +639,9 @@ function reparseCli(res,i,err){
639
639
for(i=NF=0;i in res;i++)
640
640
$(++NF)=res[i]
641
641
for(i=2;i<=NF;i++)
642
- if("\""==res[i-1,"quote"]&&!("@define"==$1&&3==i||"@depends_on"==$1&&"@args"==$3&&i>3)){
642
+ if("\""==res[i-1,"quote"]&&!("@define"==$1&&3==i||
643
+ "@depends_on"==$1&&"@args"==$3&&i>3||
644
+ "@goal"==$1&&"@glob"==$(i-1))){
643
645
addError("Wrong quoting: "$i)
644
646
return 0}
645
647
return 1}
0 commit comments