diff options
-rw-r--r-- | Makefile | 8 | ||||
-rwxr-xr-x | bin/shb | 13 | ||||
-rw-r--r-- | man/man1/shb.1df | 16 |
3 files changed, 16 insertions, 21 deletions
@@ -148,19 +148,19 @@ tmux/tmux.conf: tmux/tmux.conf.m4 tmux/tmux.conf.m4 > $@ .awk: - bin/shb $< awk -f > $@ + bin/shb awk -f < $< > $@ chmod +x -- $@ .bash: - bin/shb $< bash > $@ + bin/shb bash < $< > $@ chmod +x -- $@ .pl: - bin/shb $< perl > $@ + bin/shb perl < $< > $@ chmod +x -- $@ .sed: - bin/shb $< sed -f > $@ + bin/shb sed -f < $< > $@ chmod +x -- $@ install: install-bash \ @@ -3,15 +3,14 @@ self=shb # Need at least two arguments -if [ "$#" -lt 2 ] ; then - printf >&2 '%s: Need input file and command\n' "$self" +if [ "$#" -lt 1 ] ; then + printf >&2 '%s: Need interpreter command\n' "$self" exit 1 fi -# First argument is the script (might be - for stdin), second argument is the -# name of the interpreter -scr=$1 intn=$2 -shift 2 +# First argument is the name of the interpreter +intn=$1 +shift # Try and find the path to the interpreter command, bail out if we can't if ! intp=$(command -v "$intn" 2>/dev/null) ; then @@ -25,4 +24,4 @@ set -- "$intp" "$@" printf '#!%s\n' "$*" # Emit the rest of the input -cat -- "$scr" +cat diff --git a/man/man1/shb.1df b/man/man1/shb.1df index 1970dbde..a1cb884a 100644 --- a/man/man1/shb.1df +++ b/man/man1/shb.1df @@ -4,20 +4,16 @@ \- insert a shebang line above a file .SH SYNOPSIS .B shb -script bash +bash < foo.bash > foo .br +cat *.sed | .B shb -script sed -f -.br -command | -.B shb -- awk -f +sed -f > sedbatch .SH DESCRIPTION .B shb -searches the system paths to find a suitable program with the name given in the -second argument, forms a "shebang" line from it and any arguments beyond the -second, and then emits the contents of the first argument ('-' can be used for -stdin). +searches the system paths to find a suitable program with the name given in its +first argument, forms a "shebang" line from it and any remaining arguments, and +then emits the contents of stdin. .P This is intended as a minimal way to make portable shebang lines for Makefiles or other building or installation frameworks, handling subtleties like sed(1) |