Skip to content

Commit

Permalink
Make Grawkit POSIX-compatible, remove gawk-specific extensions
Browse files Browse the repository at this point in the history
This commit removes `gawk`-specific extensions in Grawkit, making it work for any POSIX-compatible
AWK, with `gawk`, `nawk`, `busybox awk`, and `goawk` passing the test suite successfully.

The largest changes are related to removing `match` extensions for capturing groups; these were used
for parsing command-lines, and have now being handled in the `parse_command` function in a more robust
way.

Other small changes have been made to the included `Makefile` for allowing tests to run against
different AWK implementations.
  • Loading branch information
deuill committed Aug 11, 2019
1 parent fada2ba commit 23bfc9f
Show file tree
Hide file tree
Showing 3 changed files with 183 additions and 88 deletions.
25 changes: 13 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,30 @@
# --------------------

# Default name for Grawkit executable.
CMD = $(CURDIR)/grawkit
AWK := awk
CMD := $(CURDIR)/grawkit

# Default executables to use.
SHELL = /bin/bash
DIFF = $(shell which colordiff 2> /dev/null || which diff)
SHELL := /bin/bash
DIFF := $(shell which colordiff 2> /dev/null || which diff)

# Test files to execute.
TESTS ?= $(shell find tests/*)
TESTS := $(shell find tests/*)

# Color & style definitions.
BOLD = \033[1m
UNDERLINE = \033[4m
RED = \033[31m
GREEN = \033[32m
BLUE = \033[36m
RESET = \033[0m
BOLD := \033[1m
UNDERLINE := \033[4m
RED := \033[31m
GREEN := \033[32m
BLUE := \033[36m
RESET := \033[0m

# ----------------
# Other directives
# ----------------

# Make `help` be the default action when no arguments are passed to `make`.
.DEFAULT_GOAL = help
.DEFAULT_GOAL := help
.PHONY: $(TESTS) test help

# Awk script for extracting Grawkit documentation as Markdown.
Expand Down Expand Up @@ -73,7 +74,7 @@ test-after:
$(TESTS):
$(eval TEST_$@ := awk '/<!--/ {f=1;next} /-->/ {exit} f' $@)
$(eval EXPECTED_$@ := awk '/-->/ {f=1;getline;next} f' $@)
$(eval ACTUAL_$@ := $(CMD) <($(TEST_$@)))
$(eval ACTUAL_$@ := $(AWK) -f $(CMD) <($(TEST_$@)))

@printf ">> $(BOLD)Testing file '$@'...$(RESET) "

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ A full test-suite is provided (depending only on `make` and `awk`), which should
## Installation

Copy the included `grawkit` AWK script into your local search path (most commonly
`$HOME/.local/bin`), or just use it directly in this folder.
`$HOME/.local/bin`), or just use it directly in this folder. Grawkit should work with most
POSIX-compatible AWK implementations, and has been tested against `gawk`, `nawk`, `busybox awk`, and `goawk`.

## Status & Usage

Expand Down
Loading

0 comments on commit 23bfc9f

Please sign in to comment.