From 6e603db0d71a49b499313eca7bb7d8e7ef9c492e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Mon, 28 Jun 2021 16:48:04 +0200 Subject: list: Use getopt --- list/list | 13 +++++++++---- list/list.1 | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/list/list b/list/list index 64ec8ac..d9dc558 100755 --- a/list/list +++ b/list/list @@ -1,13 +1,18 @@ -#!/usr/bin/perl -ps +#!/usr/bin/perl -p # list -- escape code listing for troff +use Getopt::Std; +BEGIN { getopt('Ep:s:'); } + if (/^\.\s*l\(\s*$/ .. /^\.\s*l\)\s*$/) { - not $E and s/^\\!// and next; + not $opt_E and s/^\\!// and next; if (/^\.\s*l\(\s*$/) { - print "$p\n" if $p; + $_ = ''; + $_ = "$opt_p\n" if $opt_p; } elsif (/^\.\s*l\)\s*$/) { - print "$s\n" if $s; + $_ = ''; + $_ = "$opt_s\n" if $opt_s; } else { s/\\/\\$&/g; s/^/\\&/g; diff --git a/list/list.1 b/list/list.1 index 085bb20..02a89d8 100644 --- a/list/list.1 +++ b/list/list.1 @@ -7,9 +7,9 @@ . .Sh SYNOPSIS .Nm -.Op Fl p=prefix -.Op Fl s=suffix .Op Fl E +.Op Fl p Ar prefix +.Op Fl s Ar suffix .Op Ar file .Sh DESCRIPTION .Pp -- cgit v1.2.3