1
0

it doesnt work

This commit is contained in:
dtb 2023-08-10 15:26:23 -04:00
parent 0f6008d758
commit a490eb13ae

66
com/com
View File

@ -39,38 +39,46 @@ test -n "$1" \
>.comfile >.comfile
while test -n "$1" awk -v argv0="$argv0" -v shell="$shell" '
do # https://www.gnu.org/software/gawk/manual/html_node/Filetrans-Function.html
cmd="$(<"$1" awk ' FILENAME != current_file {
processed == 0 && /\/\*%/ { processed = 0;
sub(/.*\/\*%[space]*/, ""); if(current_file != 0){
for(i = 0; i < length($0) - 1; ++i){ print current_file >>".comfile";
if(substr($0, i, 2) == "##" || substr($0, i, 2) == "%%") if(cmd == ""){
printf("%s", substr($0, i++, 1)) # https://www.gnu.org/software/gawk/manual/html_node/
else if(substr($0, i, 1) == "#"){ # Special-FD.html
if(stem == 0){ printf("%s: no command\n", ARGV[2]) >"/dev/stderr";
stem = ARGV[1]; exit 65 # sysexits(3) EX_DATAERR
sub(/\.[^.]*$/, "", stem) }else{
} print cmd | shell;
printf("%s", stem) cmd = "";
}else if(substr($0, i, 1) == "%") }
printf("%s", ARGV[1])
else
printf("%s", substr($0, i, 1))
} }
printf("%s\n", substr($0, i, 2)) current_file = FILENAME;
processed = 1 }
cmd == "" && /\/\*%/ {
sub(/.*\/\*%[:space:]*/, "");
stem = FILENAME;
sub(/\.[^.]*$/, "", stem);
for(i = 0; i < length($0) - 1; ++i)
cmd = cmd ((substr($0, i, 2) == "##" || substr($0, i, 2) == "%%") \
? substr($0, i++, 1) \
: (substr($0, i, 1) == "%") \
? FILENAME \
: (substr($0, i, 1) == "#") \
? stem \
: substr($0, i, 1)) \
;
cmd = cmd substr($0, i, 2);
} }
END { END {
print current_file >>".comfile";
if(cmd != "")
print cmd | shell;
if(processed == 0){ if(processed == 0){
# https://www.gnu.org/software/gawk/manual/html_node/ printf("%s: no command\n", argv0) > "/dev/stderr";
# Special-FD.html exit 65; # sysexits(3) EX_DATAERR
printf("%s: no command\n", ARGV[2]) > "/dev/stderr"
exit 65 # sysexits(3) EX_DATAERR
} }
} }
' "$1" "$argv0")" && exit 65 # sysexits(3) DATA_ERR '
$shell "$cmd"
printf '%s\n' "$1" >>.comfile
shift
done