Skip to content

Commit

Permalink
Use gawk's gettimeofday if available #57 : fix for mawk
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Sep 26, 2021
1 parent edd11f6 commit aafd632
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Makesurefile
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@
@goal stable_version_prepared @private
{
echo '#!/bin/sh'
echo "command -v gawk >/dev/null && AWK='gawk -ltime -v Gawk=1' || AWK=awk"
echo "if command -v gawk >/dev/null;then AWK='gawk -ltime -v Gawk=1'; X='';else AWK=awk; X=';function gettimeofday(){}';fi"
echo "exec \$AWK -v \"Version=$NEXT_VERSION\" -v \"Prog=\$0\" '"
awk -v Q=\' '
function trim(s) { sub(/^[ \t\r\n]+/, "", s); sub(/[ \t\r\n]+$/, "", s); return s }
/^BEGIN/ { in_begin=1 }
in_begin && /^}/ { in_begin=0 }
in_begin && $1 ~ /^split/ { next }
{ gsub("\\s*#.+$", ""); gsub(Q, Q "\\" Q Q); if (trim($0)) print}' makesure.awk
echo \'' Makesurefile "$@"'
echo \''$X Makesurefile "$@"'
} > makesure_stable

@goal default
Expand Down
4 changes: 2 additions & 2 deletions makesure_stable
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
command -v gawk >/dev/null && AWK='gawk -ltime -v Gawk=1' || AWK=awk
if command -v gawk >/dev/null;then AWK='gawk -ltime -v Gawk=1'; X='';else AWK=awk; X=';function gettimeofday(){}';fi
exec $AWK -v "Version=0.9.10" -v "Prog=$0" '
BEGIN {
Shell = "bash"
Expand Down Expand Up @@ -585,4 +585,4 @@ function isDir(path) { return ok("test -d " quoteArg(path)) }
function rm(f) { system("rm " quoteArg(f)) }
function quoteArg(a) { gsub("'\''", "'\''\\'\'''\''", a); return "'\''" a "'\''" }
function trim(s) { sub(/^[ \t\r\n]+/, "", s); sub(/[ \t\r\n]+$/, "", s); return s }
' Makesurefile "$@"
'$X Makesurefile "$@"

0 comments on commit aafd632

Please sign in to comment.