=== modified file 'README' --- README 2015-12-21 21:07:36 +0000 +++ README 2015-11-27 18:23:20 +0000 @@ -94,11 +94,6 @@ "f" - when removing existing file, do it forcibly (rm -f) "p" - create parent directories if they don't exist (mkdir -p) -? - TODO - flags: - "i" - redirect stdin from the file for the command - Commandline utilities: fileset [file [file ...]] === modified file 'bin/fileset.awk' --- bin/fileset.awk 2015-12-21 21:07:36 +0000 +++ bin/fileset.awk 2015-12-10 00:04:45 +0000 @@ -10,7 +10,6 @@ } func_num=0 - has_cond="" } function escaped(str) { @@ -50,22 +49,6 @@ print indent str } -function print_cond(statement, suffix) { # TODO - if(has_cond == "") { - print_b("if ! $check_only; then") - print_d("{ "statement"\n}"suffix) - print_e("fi") - } else { - if(suffix) { - funcs["do_" has_cond] = "{ "statement"\n}"suffix - } else { - funcs["do_" has_cond] = statement - } - print_d("req " has_cond) - has_cond = "" - } -} - function print_rsfilter(str) { if ("RSFILTER" in ENVIRON) { print str >>ENVIRON["RSFILTER"] @@ -173,28 +156,24 @@ } # cat, copy, content; eats rest of statement and puts it into the file - if(cchar ~ /[bBcC]/) { + if(cchar ~ /[cC]/) { shellfunc("f 1", crest) - content = get_argument(cchar ~ "BC") + content = get_argument(cchar == "C") + + # unless disabled with the N flag, append newline at the end of + # last line, if not already present + printf_fmt = crest ~ /n/ || (crest !~ /N/ && content !~ /\n$/) ? \ + "%s\\n" : "%s" func_name = "fn" func_num++ - - if(cchar ~ /[bB]/) { - funcs[func_name] = "\tbase64 <<<"quoted(content) - } else { - # unless disabled with the N flag, append newline at the end of - # last line, if not already present - printf_fmt = crest ~ /n/ || (crest !~ /N/ && content !~ /\n$/) ? \ - "%s\\n" : "%s" - funcs[func_name] = "\tprintf '"printf_fmt"' "quoted(content) - } + funcs[func_name] = "\tprintf '"printf_fmt"' "quoted(content) if(crest ~ /a/) { - print_cond(func_name, ">>"fname) - } else if(has_cond == "") { + print_b("if ! $check_only; then") + print_i(func_name " >>" fname) + print_e("fi") + } else { print_i("c " func_name) - } else { - print_cond("c "func_name) } continue } @@ -232,35 +211,31 @@ print_d("rm "fname".tmp.$$") # use file as Input } else if(crest ~ /i/) { - print_cond(statement, "<"fname) + print_b("if ! $check_only; then") + print_d("{ "statement"\n} <"fname) + print_e("fi") # use file as Output } else if(crest ~ /o/) { shellfunc("req type_or_missing f", crest) - print_cond(statement, ">"fname) + print_b("if ! $check_only; then") + print_d("{ "statement"\n} >"fname) + print_e("fi") # Append to file } else if(crest ~ /a/) { shellfunc("req type_or_missing f", crest) - print_cond(statement, ">>"fname) + print_b("if ! $check_only; then") + print_d("{ "statement"\n} >>"fname) + print_e("fi") # do nothing special with file } else { - print_cond(statement) + print_b("if ! $check_only; then") + print_d("{ "statement"\n}") + print_e("fi") } statement = "" continue } - # shell condition - if(cchar == "?") { - has_cond = func_num++ - if(crest ~ /i/) { - funcs["cond_" has_cond] = ( \ - "{ "statement"\n} <"fname \ - ) - } else { - funcs["cond_" has_cond] = statement - } - } - # if none above matched printf "unrecognised statement: %s\n", cchar crest statement >"/dev/stderr" statement = ""