it doesnt work
This commit is contained in:
parent
0f6008d758
commit
a490eb13ae
68
com/com
68
com/com
@ -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))
|
|
||||||
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){
|
|
||||||
# https://www.gnu.org/software/gawk/manual/html_node/
|
# https://www.gnu.org/software/gawk/manual/html_node/
|
||||||
# Special-FD.html
|
# 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
|
exit 65 # sysexits(3) EX_DATAERR
|
||||||
|
}else{
|
||||||
|
print cmd | shell;
|
||||||
|
cmd = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
' "$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