1
0

it doesnt work

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

68
com/com
View File

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