From e5a30c97a6cbf8921f356671b60f9f9426694228 Mon Sep 17 00:00:00 2001 From: xonix Date: Wed, 13 Mar 2024 21:26:29 +0200 Subject: [PATCH 1/3] Release 0.9.23 #163 --- Makesurefile | 2 +- README.md | 2 +- makesure | 22 ++++++++++++---------- makesure_candidate | 4 ++-- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Makesurefile b/Makesurefile index 6c1490e..92c6d16 100644 --- a/Makesurefile +++ b/Makesurefile @@ -1,7 +1,7 @@ # vim: syntax=bash @options timing -@define NEXT_VERSION '0.9.22' +@define NEXT_VERSION '0.9.23' @define GOAWK_VERSION '1.25.0' @define JUST_VERSION '1.3.0' @define FHTAGN_VERSION 'v0.1.1' diff --git a/README.md b/README.md index 0e300e3..9ec442b 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ By default, all scripts inside goals are executed with `bash`. If you want to us ``` $ ./makesure -h -makesure ver. 0.9.22 +makesure ver. 0.9.23 Usage: makesure [options...] [-f buildfile] [goals...] -f,--file buildfile set buildfile to use (default Makesurefile) diff --git a/makesure b/makesure index 66648c5..e2bb572 100755 --- a/makesure +++ b/makesure @@ -1,6 +1,6 @@ #!/bin/sh 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 -exec $makesure_awk -v "Version=0.9.22" -v "Prog=$0" "$makesure_pre"' +exec $makesure_awk -v "Version=0.9.23" -v "Prog=$0" "$makesure_pre"' BEGIN { Shell="bash" SupportedShells["bash"] @@ -103,7 +103,7 @@ function handleDefine(){ if(NF!=3){ addError("Invalid @define syntax, should be @define VAR_NAME '\''value'\''") return} - if($2 !~ /^[A-Za-z_][A-Za-z0-9_]*$/){ + if($2!~/^[A-Za-z_][A-Za-z0-9_]*$/){ addError("Wrong variable name: '\''"$2"'\''") return} if(!($2 in DefineOverrides)) @@ -143,7 +143,7 @@ function handleGoal(i,goalName){ GoalParams[goalName,GoalParamsCnt[goalName]++]=validateParamName($i) }else if(NF>2)addError("nothing allowed after goal name")} function validateParamName(p){ - if(p !~ /^[A-Z_][A-Z0-9_]*$/)addError("@param name should match /^[A-Z_][A-Z0-9_]*$/: '\''"p"'\''") + if(p!~/^[A-Z_][A-Z0-9_]*$/)addError("@param name should match /^[A-Z_][A-Z0-9_]*$/: '\''"p"'\''") return p} function registerGoal(priv,goalName){ if(""==goalName||"@params"==goalName) @@ -180,7 +180,7 @@ function handleGoalGlob(goalName,globAllGoal,globSingle,priv,i,pattern,nfMax,gi, }else pattern=$(nfMax=4) if(NF>nfMax&&"@params"!=$(nfMax+1)) - addError("nothing or @params allowed after glob pattern") + addError("nothing or @params allowed after glob pattern") else if(pattern=="") addError("absent glob pattern") else { @@ -389,7 +389,7 @@ function shellExec(script,comment,res){ function getMyDir(makesurefilePath){ return executeGetLine("cd \"$(dirname "quoteArg(makesurefilePath)")\";pwd")} function handleCodeLine(line){ - if(!isCodeAllowed()&&line !~ /^[ \t]*#/&&trim(line)!=""){ + if(!isCodeAllowed()&&line!~/^[ \t]*#/&&trim(line)!=""){ if(!ShellInPreludeErrorShown++) addError("Shell code is not allowed outside goals/libs") }else @@ -454,7 +454,7 @@ function instantiate(goal,args,newArgs,i,j,depArg,depArgType,dep,goalNameInstant copyKey(goal,goalNameInstantiated,ReachedIf) copyKey(goal,goalNameInstantiated,GoalToLib) for(i in args) - argsCode=addL(argsCode,i"="quoteArg(args[i])) + argsCode=addL(argsCode,i"="quoteArg(args[i])";export "i) CodePre[goalNameInstantiated]=addL(CodePre[goalNameInstantiated],argsCode) if(goalNameInstantiated in ReachedIf) 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 return"unterminated argument" if(!inDef&&":"==c&&"-"==substr(line,pos+1,1)){ inDef=1 - c=substr(line,pos += 2,1)} + c=substr(line,pos+=2,1)} if(inDef){ if("}"==c) break @@ -613,7 +613,7 @@ function parseCli_2(line,vars,vars2,res,pos,c,c1,isDoll,q,var,inDef,defVal,val,w }else for(;(c=substr(line,pos+1,1))~/[_A-Za-z0-9]/;pos++) var=var c - if(var !~ /^[_A-Za-z][_A-Za-z0-9]*$/) + if(var!~/^[_A-Za-z][_A-Za-z0-9]*$/) return"wrong var: '\''"var"'\''" w=(w)((val=var in vars?vars[var]:var in vars2?vars2[var]:ENVIRON[var])!=""?val:defVal) continue} @@ -626,7 +626,7 @@ function parseCli_2(line,vars,vars2,res,pos,c,c1,isDoll,q,var,inDef,defVal,val,w w=c while((c=substr(line,++pos,1))!=""&&c!=" "&&c!="\t"){ w=w c} - if(w !~ /^[_A-Za-z0-9@.]+$/) + if(w!~/^[-_A-Za-z0-9@.]+$/) return"wrong unquoted: '\''"w"'\''" res[i=+res[-7]++,"quote"]="u" res[i]=w}}}} @@ -639,7 +639,9 @@ function reparseCli(res,i,err){ for(i=NF=0;i in res;i++) $(++NF)=res[i] for(i=2;i<=NF;i++) - if("\""==res[i-1,"quote"]&&!("@define"==$1&&3==i||"@depends_on"==$1&&"@args"==$3&&i>3)){ + if("\""==res[i-1,"quote"]&&!("@define"==$1&&3==i|| +"@depends_on"==$1&&"@args"==$3&&i>3|| +"@goal"==$1&&"@glob"==$(i-1))){ addError("Wrong quoting: "$i) return 0} return 1} diff --git a/makesure_candidate b/makesure_candidate index 5813d2f..e2bb572 100755 --- a/makesure_candidate +++ b/makesure_candidate @@ -1,6 +1,6 @@ #!/bin/sh 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 -exec $makesure_awk -v "Version=0.9.22" -v "Prog=$0" "$makesure_pre"' +exec $makesure_awk -v "Version=0.9.23" -v "Prog=$0" "$makesure_pre"' BEGIN { Shell="bash" SupportedShells["bash"] @@ -626,7 +626,7 @@ function parseCli_2(line,vars,vars2,res,pos,c,c1,isDoll,q,var,inDef,defVal,val,w w=c while((c=substr(line,++pos,1))!=""&&c!=" "&&c!="\t"){ w=w c} - if(w!~/^[_A-Za-z0-9@.]+$/) + if(w!~/^[-_A-Za-z0-9@.]+$/) return"wrong unquoted: '\''"w"'\''" res[i=+res[-7]++,"quote"]="u" res[i]=w}}}} From 6bf6b56cbeefc16c3e89a865b54c641c707c21c7 Mon Sep 17 00:00:00 2001 From: xonix Date: Wed, 13 Mar 2024 21:30:55 +0200 Subject: [PATCH 2/3] Release 0.9.23 #163 --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f74dbd0..0773e7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## v0.9.23 + +- Allow glob to be interpolated string to facilitate reuse [#165](https://github.com/xonixx/makesure/issues/165) +- Minor improvements and fixes. + ## v0.9.22 - Main theme of this release is allowing glob goals to be parameterized [#155](https://github.com/xonixx/makesure/issues/155) - Support interpolation including parameterized goal params [#153](https://github.com/xonixx/makesure/issues/153) From be8dd3acbc91d45e2c52fb9f260d553d18b6f52d Mon Sep 17 00:00:00 2001 From: xonix Date: Wed, 13 Mar 2024 21:37:23 +0200 Subject: [PATCH 3/3] rm obsolete file Makesure.md --- Makesure.md | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) delete mode 100644 Makesure.md diff --git a/Makesure.md b/Makesure.md deleted file mode 100644 index 15a8a90..0000000 --- a/Makesure.md +++ /dev/null @@ -1,48 +0,0 @@ - -## Plan - -1. [x] Each goal execution should not create shared variables - this can introduce unwanted intent to rely on imperative execution model -2. prelude - - [x] prelude runs exactly 1 time - - [x] goal is to initialize variables - - [x] use @define to export variable for goals - - [x] reuse export for MVP -3. [x] Goals topological sort -4. [ ] \[DECIDE] Profiles a-la maven -5. [ ] \[DECIDE] Find a way to share functions -6. [ ] \[DECIDE] Pre-check? Post-check? -7. [x] make @shell configurable -8. [x] \[REJECT] `-p` flag to print generated bash script -9. [x] provide goals to run as argument -10. [x] `-l` flag to show all goals -11. [x] per-goal documentation -12. [x] Make makesure to use Makesurefile file by default -13. [x] Agree on single standard way to run the scenario -14. [x] dependency validation - non-existent dep -15. [x] dependency validation - cycle -16. [x] @reached_if should run before dependencies -17. [ ] show actual dependency loop path -18. [x] mention each goal executed - now doesn't print if goal has empty body -19. [x] handle custom build file via `-f` - - [x] `-f` to handle folder with `Makesurefile` -20. [x] `-v` flag to show version -21. [x] `-d` flag to show resolved dependencies -22. [x] introduce test suite via tush -23. [x] `-t` flag for timing for goals execution - - [x] is it possible to ms precision? - - [x] measure each goal -24. [x] `-h` flag for help -25. [ ] \[DECIDE] `-F` to force build despite the reached_if -26. [x] `-x` to enable tracing in bash -27. [x] support `@options silent` mode and flag `-s` -28. [x] allow override @define-s - - [x] `-D "var=val"` / `--define "var=val"` -29. [x] support @options directive - - [x] @options tracing - - [x] @options silent - - [x] @options timing -30. [x] find a way to enable tracing for the prelude - this correlates with "prelude runs exactly 1 time" - -## Ideas proved not to work - - Idea with stupid_flush (which just sends 65K spaces to shell pipe) is broken: - - we can't handle correctly the situation when bash fails for wrong command, and we keep sending to broken pipe \ No newline at end of file