aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.markdown2
-rwxr-xr-xbin/pp14
-rwxr-xr-xbin/pph5
-rw-r--r--man/man1/pp.1df17
-rw-r--r--man/man1/pph.1df16
5 files changed, 54 insertions, 0 deletions
diff --git a/README.markdown b/README.markdown
index e2abeb96..97823267 100644
--- a/README.markdown
+++ b/README.markdown
@@ -478,6 +478,8 @@ Installed by the `install-bin` target:
* `motd(1df)` shows the system MOTD.
* `onl(1df)` crunches input down to one printable line.
* `pa(1df)` prints its arguments, one per line.
+* `pp(1df)` prints the full path of each argument using `$PWD`.
+* `pph(1df)` runs `pp(1df)` and includes a leading `$HOSTNAME:`.
* `paz(1df)` print its arguments terminated by NULL chars.
* `pit(1df)` runs its input through a pager if its standard output looks like
a terminal.
diff --git a/bin/pp b/bin/pp
new file mode 100755
index 00000000..d9e45f92
--- /dev/null
+++ b/bin/pp
@@ -0,0 +1,14 @@
+#!/bin/sh
+# Print the full path to each argument; file need not exist
+for arg ; do
+ case $arg in
+ */*)
+ dir=$(cd -- "${arg%/*}" ; printf '%s/' "$PWD")
+ dir=${dir%/}
+ ;;
+ *)
+ dir=$PWD
+ ;;
+ esac
+ printf '%s/%s\n' "$dir" "${arg##*/}"
+done
diff --git a/bin/pph b/bin/pph
new file mode 100755
index 00000000..684aaafd
--- /dev/null
+++ b/bin/pph
@@ -0,0 +1,5 @@
+#!/bin/sh
+# Run pp(1df) on args, prefix with machine hostname
+hostname=$(hostname -s) || exit
+pp "$@" |
+sed 's_^_'"$hostname":'_'
diff --git a/man/man1/pp.1df b/man/man1/pp.1df
new file mode 100644
index 00000000..1c7aca70
--- /dev/null
+++ b/man/man1/pp.1df
@@ -0,0 +1,17 @@
+.TH PP 1df "January 2017" "Manual page for pp"
+.SH NAME
+.B pp
+\- print the full path to each argument
+.SH SYNOPSIS
+.B pp
+/arg arg2 ./arg3
+.SH DESCRIPTION
+.B pp
+uses $PWD to print the full path to each of its arguments, unless they begin
+with a slash, in which case they are printed verbatim.
+.SH CAVEATS
+Newlines in filenames will still work, but the results won't really make sense
+as they'll be indistinguishable from newlines separating the files. This is for
+generating human-readable file lists, not for machines.
+.SH AUTHOR
+Tom Ryder <tom@sanctum.geek.nz>
diff --git a/man/man1/pph.1df b/man/man1/pph.1df
new file mode 100644
index 00000000..0ad98fc5
--- /dev/null
+++ b/man/man1/pph.1df
@@ -0,0 +1,16 @@
+.TH PPH 1df "January 2017" "Manual page for pp"
+.SH NAME
+.B pp
+\- print the full path to each argument, hostname prepended
+.SH SYNOPSIS
+.B pp
+/arg arg2 ./arg3
+.SH DESCRIPTION
+.B pph
+runs pp(1df) on the arguments to print the full path to each one, and also
+prepends the machine's hostname and a colon to each line.
+.SH CAVEATS
+Newlines in filenames will mess this up. This is for generating human-readable
+file lists, not for machines.
+.SH AUTHOR
+Tom Ryder <tom@sanctum.geek.nz>