Skip to content

Remove the fixed filter-slot limit in noweave - #56

Open
dbosk wants to merge 1 commit into
nrnrnr:masterfrom
dbosk:generalise-filter-pipeline
Open

dbosk wants to merge 1 commit into
nrnrnr:masterfrom
dbosk:generalise-filter-pipeline

Conversation

@dbosk

@dbosk dbosk commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

noweave enumerated seven filter slots (filtera..filterg) with copy-pasted if/elif ladders, a workaround for a portable /bin/sh having no arrays. Stacking enough -autodefs and -filter stages exhausted them with "ran out of filters".

This accumulates filters in one newline-separated variable, appends in O(1), and builds the pipeline by joining the lines with | and running them through a single eval. Newline is a safe separator: a filter command carries spaces but never a newline. The number of filters is now unbounded. Only the pipeline plumbing in src/shell/noweave.nw (and the tangled noweave) changes, so this is independent of any filter.

Test plan

  • stdout and stderr byte-for-byte identical to the old script on the shipped examples for: no filter, -x, -index -autodefs c, -html -filter l2h, -delay -filter btdefn, -filter 'elide foo:*' (quoted argument with a glob), -indexfrom, -v, and a seven-filter pipeline
  • an eight-filter pipeline, which the old script refused, runs and produces the same output as the equivalent shorter one
  • notangle.1 unchanged (no man-page chunk touched)

🤖 Generated with Claude Code

https://claude.ai/code/session_01HsqKrvJ5u3A589XGjj9doX

noweave enumerated seven filter slots (filtera..filterg) with
copy-pasted if/elif ladders, a workaround for a portable /bin/sh
having no arrays.  Stacking enough -autodefs and -filter stages
exhausted them with "ran out of filters".

Accumulate filters in one newline-separated variable instead, append
in O(1), and build the pipeline by joining the lines with "|" and
running them through a single eval.  Newline is a safe separator: a
filter command carries spaces but never a newline.  The append stays
on one source line, routing the newline through an nl variable, so
noweb's continuation-line reindentation cannot splice spaces into the
list.  The verbose listing restores the normal IFS before each echo so
its output stays identical too.

The number of filters is now unbounded.  Standard output and standard
error are byte-for-byte identical to the old script for the no-filter,
-x, -index/-autodefs, -html/-filter, -delay, -indexfrom, quoted-filter-
argument, verbose and seven-filter cases on the shipped examples; an
eight-filter pipeline, which the old script refused, now runs and
produces the same output as the equivalent shorter one.

This is the standalone form of the change: it touches only the
pipeline plumbing, so it can be merged independently of any filter.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HsqKrvJ5u3A589XGjj9doX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant