commit 4722de8c153cbd6970a2304da871def0d5f09435
parent b3942e17c8305b2185a8fea76ab55b3626cbde54
Author: Jan Pobrislo <ccx@webprojekty.cz>
Date: Wed, 13 Feb 2019 13:07:30 +0100
Fixes for conditional script execution command
Diffstat:
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/README b/README
@@ -101,7 +101,10 @@ Flags taken by the rfdlhcLHC commands:
"p" - create parent directories if they don't exist (mkdir -p)
?<flags><tab><command>
- TODO
+ Modifies following ! command. The command specified as argument will be run
+ to determine the following ! command should be run
+ (if ? command exits nonzero) and if so it's used once again after
+ to check that ! command performed required action (when ? command exits zero).
flags:
"i" - redirect stdin from the file for the command
diff --git a/bin/fileset.awk b/bin/fileset.awk
@@ -107,6 +107,15 @@ function process_statement() {
cchar = substr(command, 1, 1)
crest = substr(command, 2)
+ # check before the command is processed if we have dangling "?"
+ if(cchar != "!" && has_cond != "") {
+ printf "%s:%s: ? is not followed by ! (superfluous condition): %s\n", FILENAME, FNR, \
+ cchar crest statement >"/dev/stderr"
+ if(!WARN_ONLY) {
+ exit 1
+ }
+ }
+
# set current fname all subsequent operations will be performed on
if(cchar == "/") {
curpath = crest
@@ -245,12 +254,14 @@ function process_statement() {
if(cchar == "?") {
has_cond = func_num++
if(crest ~ /i/) {
- funcs["cond_" has_cond] = ( \
+ funcs["check_" has_cond] = ( \
"{ "statement"\n} <"fname \
)
} else {
- funcs["cond_" has_cond] = statement
+ funcs["check_" has_cond] = statement
}
+ statement = ""
+ continue
}
# if none above matched