diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | README.markdown | 1 | ||||
-rw-r--r-- | bin/jfp.sed | 4 | ||||
-rw-r--r-- | man/man1/jfp.1df | 39 |
5 files changed, 46 insertions, 0 deletions
@@ -2,6 +2,7 @@ bin/brnl bin/csmw bin/ddup bin/gwp +bin/jfp bin/han bin/htdec bin/htenc @@ -74,6 +74,7 @@ BINS = bin/brnl \ bin/han \ bin/htdec \ bin/htenc \ + bin/jfp \ bin/max \ bin/mean \ bin/med \ diff --git a/README.markdown b/README.markdown index 2767e04e..e2abeb96 100644 --- a/README.markdown +++ b/README.markdown @@ -464,6 +464,7 @@ Installed by the `install-bin` target: repository. * `ix(1df)` posts its input to the ix.io pastebin. * `jfc(1df)` adds and commits lazily to a Git repository. +* `jfp(1df)` prints its input, excluding any shebang on the first line only. * `jfcd(1df)` watches a directory for changes and runs `jfc(1df)` if it sees any. * `loc(1df)` is a quick-search wrapped around `find(1)`. diff --git a/bin/jfp.sed b/bin/jfp.sed new file mode 100644 index 00000000..c3c43145 --- /dev/null +++ b/bin/jfp.sed @@ -0,0 +1,4 @@ +#!/bin/sed -f +1 { + /^\#!/d +} diff --git a/man/man1/jfp.1df b/man/man1/jfp.1df new file mode 100644 index 00000000..6e9e18f2 --- /dev/null +++ b/man/man1/jfp.1df @@ -0,0 +1,39 @@ +.TH JFP 1df "January 2017" "Manual page for jfp" +.SH NAME +.B jfp +\- print input, excluding any shebang on the first line +.SH SYNOPSIS +.B jfp +FILE [FILE2 ...] +.br +.B jfp +< FILE +.P +#!/usr/bin/env jfp +.br +All this content will be printed verbatim, +.br +except for the first line, +.br +because it's a shebang. +.SH DESCRIPTION +.B jfp +prints all the input given to it except for the first line if it starts with a +shebang "#!". This means it can be used in a shebang to simply echo the entire +remaining contents of the script. +.SH NOTES +Can you guess what it stands for? +.P +A portable way to do the same thing could be using a heredoc with cat(1): +.P + #!/bin/sh + cat <<'EOD' + All this content will be printed verbatim... + ...except for the first line... + ...because it's a shebang. + EOD +.P +The only snag there is having to check the token word doesn't appear in the +document. +.SH AUTHOR +Tom Ryder <tom@sanctum.geek.nz> |