From 9311bd5ea1a9b062c2a1f88fe768829ffc3c004b Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Sat, 7 Sep 2019 16:39:29 +0200 Subject: [PATCH] compile regular expression to -f (without /x) Reports syntax errors immediately. --- barcat | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/barcat b/barcat index 3e1980d..6d56109 100755 --- a/barcat +++ b/barcat @@ -18,7 +18,10 @@ GetOptions(\%opt, 'color|c!', 'C' => sub { $opt{color} = 0 }, 'field|f=s' => sub { - $opt{anchor} = /^[0-9]+$/ ? qr/(?:\S*\h+){$_}\K/ : $_ for $_[1]; + eval { + local $_ = $_[1]; + $opt{anchor} = /^[0-9]+$/ ? qr/(?:\S*\h+){$_}\K/ : qr/$_/; + } or die "$@ for option $_[0]\n"; }, 'human-readable|H!', 'interval|t:i', -- 2.30.0