From 3319d70e4e8fd89fe6140e95504a718717bd4e80 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 15 Mar 2023 14:24:10 -0500 Subject: Rewrite with sh --- Makefile | 15 +++-- README.md | 35 ++++------- shin | 203 ++++++++++++++++++++++++++++++++++++++++++++++---------------- shin.awk | 60 ------------------- shin.sh | 119 ------------------------------------ shinb | 7 +++ 6 files changed, 179 insertions(+), 260 deletions(-) delete mode 100755 shin.awk delete mode 100755 shin.sh create mode 100755 shinb diff --git a/Makefile b/Makefile index a9401a1..b6efa17 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,12 @@ NAME = shin DESC = Include shell scripts in other shell scripts +INSTALLED = shin shinb + DESTDIR = PREFIX = /usr/local -BIN = $(DESTDIR)$(PREFIX)/bin/$(NAME) +BIN = $(DESTDIR)$(PREFIX)/bin .PHONY: help help: @@ -19,13 +21,16 @@ help: @echo " uninstall Uninstall $(NAME)-related files." .PHONY: install -install: $(NAME) - install -D $< $(BIN) +install: $(INSTALLED) + install -Dt $(BIN) $? .PHONY: link -link: - ln -sf $(PWD)/$(NAME) $(BIN) +link: $(NAME) shinb $(BIN) + ln -sf $(PWD)/$(NAME) $(PWD)/shinb $(BIN) .PHONY: uninstall uninstall: rm $(BIN) + +$(BIN): + mkdir -p $(BIN) diff --git a/README.md b/README.md index 4b68c96..f6f03d8 100644 --- a/README.md +++ b/README.md @@ -2,35 +2,24 @@ ## include shell files built to scratch a personal itch. SHIN is an awk(1) script that plops include -files in to .shin files. here's the usage text: +files in to .shin files. -``` -SHIN: include shell files in other shell files -USAGE: shin FILE... - -FILEs named FILE.shin will be built to FILE.sh in the same directory. -to include files in shin files, use the following comment syntax: +recently rewritten. now use it like this: -#< INCLUDE +```sh +#!/bin/sh -shin will add INCLUDE below that comment, as well as a comment -denoting the end of INCLUDE. -``` +. shin # if shin is in $PATH this should Just Work(TM) -it's really that simple. and stupid. +do_stuff_here -## configuration +shin included_file -SHIN will look for include files in the current directory, unless you set the -SHINPATH environment variable. $SHINPATH is a colon-separated list of -directories like $PATH or $MANPATH. - -## extras +other_stuff +``` -`shin.awk` is the plain awk script. because awk is dumb about handling -arguments, `shin` is a shell script that will do `shin.awk`'s work unless you -pass `shin -h`, in which case it will print a helpful message. +you can run the above script itself, or you can "compile" it by running `shin -c