]> Pileus Git - vpaste/blobdiff - index.cgi
fix awk for head command
[vpaste] / index.cgi
index f3a4a7e76f11921aaa61c96a893a54b734fa0cd8..e311a94d62da46c87cedd9c14818d20656fde426 100755 (executable)
--- a/index.cgi
+++ b/index.cgi
@@ -71,14 +71,14 @@ function do_cmd {
        header text/plain
        case "$1" in
        head)
-               awk '
-                       BEGIN       { rows=4; cols=60; }
+               awk -v 'rows=4' -v 'cols=60' '
                        FNR==1      { gsub(/.*\//, "", FILENAME);
                                      print FILENAME
                                      print "-----" }
                        FNR==1,/^$/ { next }
                        /\S/        { i++; printf "%."cols"s\n", $0 }
-                       i>=rows     { i=0; print ""; nextfile  }
+                       i>=rows     { nextfile  }
+                       ENDFILE     { i=0; print ""  }
                ' $(ls -t db/*)
                ;;
        ls)