it doesnt work
This commit is contained in:
parent
0f6008d758
commit
a490eb13ae
66
com/com
66
com/com
@ -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))
|
||||
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";
|
||||
exit 65 # sysexits(3) EX_DATAERR
|
||||
}else{
|
||||
print cmd | shell;
|
||||
cmd = "";
|
||||
}
|
||||
}
|
||||
printf("%s\n", substr($0, i, 2))
|
||||
processed = 1
|
||||
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){
|
||||
# https://www.gnu.org/software/gawk/manual/html_node/
|
||||
# Special-FD.html
|
||||
printf("%s: no command\n", ARGV[2]) > "/dev/stderr"
|
||||
exit 65 # sysexits(3) EX_DATAERR
|
||||
printf("%s: no command\n", argv0) > "/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
|
||||
'
|
||||
|
Loading…
Reference in New Issue
Block a user