From d05041d707a7dc9c43e84ba0c7847b9003a6571b Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Fri, 7 Apr 2023 18:51:12 +0200 Subject: Genesis commit --- .gitignore | 1 + LICENSE | 14 ++++++++++++++ Makefile | 23 +++++++++++++++++++++++ README | 31 +++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 README diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b39ca3e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +fsub diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e663355 --- /dev/null +++ b/LICENSE @@ -0,0 +1,14 @@ +BSD Zero Clause License + +Copyright (c) 2023 Thomas Voss + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0c2570e --- /dev/null +++ b/Makefile @@ -0,0 +1,23 @@ +.POSIX: + +CFLAGS = -Wall -Wextra -Wpedantic -Werror \ + -O3 -march=native -mtune=native \ + -std=c11 -pipe +LDFLAGS = `pkg-config --libs libpcre2-8` + +PREFIX = /usr/local +DPREFIX = ${DESTDIR}${PREFIX} +MANDIR = ${DPREFIX}/share/man + +target = fsub + +all: ${target} +${target}: ${target}.c + +install: + mkdir -p ${DPREFIX}/bin ${MANDIR}/man1 + cp ${target} ${DPREFIX}/bin + cp *.1 ${MANDIR}/man1 + +clean: + rm -f ${target} diff --git a/README b/README new file mode 100644 index 0000000..24a4495 --- /dev/null +++ b/README @@ -0,0 +1,31 @@ + ========================================= + fsub — substitute a file into other files + ========================================= + +fsub is a command-line utility to replace substrings within files with other +files. This has a variety of usecases, such as static-site generators. Take +for example the following skeleton HTML file: + + + + + + +
+ +We want to be able to generate the table data externally, and then fill in the +above table. With fsub this is made very easy. The following commands generate +table data which is written to “data.html”, and then replace the comment in the +base file with the contents of “data.html” and write the result to “index.html”: + + $ ./generate-table-data.sh >data.html + $ fsub '' data.html base.html >index.html + +You can also use the special filename ‘-’ to represent the standard input, +allowing for usage in a pipeline: + + $ ./generate-table-data.sh + | fsub '' - base.html >index.html + +This is just a very basic overview, for more information check the fsub(1) +manual page. -- cgit v1.2.3