diff options
-rw-r--r-- | Makefile | 39 | ||||
-rw-r--r-- | README.org | 20 | ||||
-rw-r--r-- | pictor.6 | 37 | ||||
-rwxr-xr-x | pictor.pl | 10 |
4 files changed, 95 insertions, 11 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..69fb58b --- /dev/null +++ b/Makefile @@ -0,0 +1,39 @@ +# Install to /usr/local unless otherwise specified, such as `make +# PREFIX=/app`. +PREFIX?=/usr/local + +INSTALL?=install +INSTALL_PROGRAM=$(INSTALL) -Dm 755 +INSTALL_DATA=$(INSTALL) -Dm 644 + +bindir=$(DESTDIR)$(PREFIX)/bin +sharedir=$(DESTDIR)$(PREFIX)/share + +# OpenBSD doesn't index /usr/local/share/man by default so +# /usr/local/man will be used. +platform_id != uname -s +mandir != if [ $(platform_id) = OpenBSD ]; then \ + echo $(DESTDIR)$(PREFIX)/man; \ +else \ + echo $(DESTDIR)$(PREFIX)/share/man; \ +fi + +help: + @echo "targets:" + @awk -F '#' '/^[a-zA-Z0-9_-]+:.*?#/ { print $0 }' $(MAKEFILE_LIST) \ + | sed -n 's/^\(.*\): \(.*\)#\(.*\)/ \1|-\3/p' \ + | column -t -s '|' + +install: pictor.pl pictor.6 README.org # system install + $(INSTALL_PROGRAM) pictor.pl $(bindir)/pictor + + $(INSTALL_DATA) pictor.6 $(mandir)/man6/pictor.6 + $(INSTALL_DATA) README.org $(sharedir)/doc/pictor/README.org + + +uninstall: # system uninstall + rm -f $(bindir)/pictor + rm -f $(mandir)/man6/pictor.6 + rm -fr $(sharedir)/doc/pictor/ + +.PHONY: install uninstall help diff --git a/README.org b/README.org index fc6bb3f..feac322 100644 --- a/README.org +++ b/README.org @@ -1,5 +1,4 @@ -#+HTML_HEAD: <link rel="stylesheet" href="../static/style.css"> -#+HTML_HEAD: <link rel="icon" href="../static/pictor.png" type="image/png"> +#+SETUPFILE: ~/.emacs.d/org-templates/projects.org #+EXPORT_FILE_NAME: index #+TITLE: Pictor @@ -11,10 +10,19 @@ Pictor is a simple acronym expander. It's based on =wtf= program from | GitHub (Mirror) | [[https://github.com/andinus/pictor/][Pictor - GitHub]] | *Tested on*: -- OpenBSD 6.6 - - Perl v5.28 -- OpenBSD 6.7 - - Perl v5.30.2 +- OpenBSD 6.6 (Perl v5.28) +- OpenBSD 6.7 (Perl v5.30.2) +- OpenBSD 6.8 (Perl v5.30.3) *Note* (OpenBSD users): If you're using a custom Perl install then add the path to =OpenBSD::= in @INC. + +* Installation +#+BEGIN_SRC sh +# Clone the project. +git clone https://git.tilde.institute/andinus/pictor +cd pictor + +# Install. +sudo make install +#+END_SRC diff --git a/pictor.6 b/pictor.6 new file mode 100644 index 0000000..b4c5dc3 --- /dev/null +++ b/pictor.6 @@ -0,0 +1,37 @@ +.Dd $Mdocdate: November 23 2020 $ +.Dt PICTOR 6 +.Os +.Sh NAME +.Nm pictor +.Nd a simple acronym expander +.Sh SYNOPSIS +.Nm pictor +.Op Ar is +.Ar <term> +.Sh DESCRIPTION +.Nm +is a simple acronym expander. It's based on +.Ar wtf +program from +.Ar NetBSD 1.5. +.Pp +.Sh FILES +.Bl -tag -width /usr/local/share/misc/acronyms.XXXX -compact +.It Pa /usr/local/share/misc/acronyms +default acronym database. +.It Pa /usr/local/share/misc/acronyms-o +default offensive acronym database. +.It Pa /usr/local/share/misc/acronyms.comp +default computer-related acronym database. +.El +.Sh SEE ALSO +.Xr wtf 6 +.Pp +.Sh BUGS +On OpenBSD: If you're using a custom Perl install then add the path to +.Ar OpenBSD::Unveil & OpenBSD::Pledge +to +.Ar @INC. +.Pp +.Sh AUTHOR +.An Andinus Aq Mt andinus@nand.sh diff --git a/pictor.pl b/pictor.pl index b74220b..c10e360 100755 --- a/pictor.pl +++ b/pictor.pl @@ -3,6 +3,7 @@ use strict; use warnings; +# Use pledge(2) & unveil(2) on OpenBSD. use constant is_OpenBSD => $^O eq "openbsd"; if (is_OpenBSD) { require OpenBSD::Unveil; @@ -20,8 +21,7 @@ pledge( qw( stdio rpath unveil ) ) or die "Unable to pledge: $!"; # User must pass at least one argument. -die "usage: pictor term\n" - unless @ARGV > 0; +die "usage: pictor <term>\n" unless @ARGV > 0; my $term = $ARGV[0]; @@ -31,7 +31,7 @@ if ( $ARGV[0] eq "is" $term = $ARGV[1]; } -# files contains list of all files to search for acronyms. +# @files contains list of all files to search for acronyms. my @files = ( '/usr/local/share/misc/acronyms', '/usr/local/share/misc/acronyms-o', @@ -57,10 +57,10 @@ my $total_acronyms = 0; # Search for acronym in every file. foreach my $fn (@files) { - open my $fh, '<', $fn or + open my $fh, '<', $fn # The program should continue if the file doesn't exist but # warn the user about it. - do { + or do { warn "Unable to open $fn: $!\n"; next; }; |