From: Karen Etheridge Date: Wed, 4 Sep 2013 20:47:26 +0000 (-0700) Subject: look for fancy dashes byte-wise, rather than literally X-Git-Tag: 1.008012~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5eff9c2438093d9f72e3359178acc747882d890a;p=p5sagit%2Flocal-lib.git look for fancy dashes byte-wise, rather than literally If someone (e.g. me!) slaps in a 'use utf8;' into the old version of the document, then the check would always fail. This way we will catch the character even if 'use utf8' is added later. --- diff --git a/Makefile.PL b/Makefile.PL index 9632385..3d9252c 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -45,7 +45,8 @@ BEGIN { # dashes, it's better to die loudly telling the user exactly what happened # so they don't make the same mistake again rather than being the only # program in the universe that works with them. - if(grep { /−/ } @ARGV) { + # the fancy dash is U+2212 or \xE2\x88\x92 + if(grep { /\xE2\x88\x92/ } @ARGV or grep { /−/ } @ARGV) { die <<'DEATH'; WHOA THERE! It looks like you've got some fancy dashes in your commandline! These are *not* the traditional -- dashes that software recognizes. You diff --git a/lib/local/lib.pm b/lib/local/lib.pm index 2e477e6..0ae0969 100644 --- a/lib/local/lib.pm +++ b/lib/local/lib.pm @@ -29,7 +29,8 @@ sub import { my %arg_store; for my $arg (@args) { # check for lethal dash first to stop processing before causing problems - if ($arg =~ /−/) { + # the fancy dash is U+2212 or \xE2\x88\x92 + if ($arg =~ /\xE2\x88\x92/ or $arg =~ /−/) { die <<'DEATH'; WHOA THERE! It looks like you've got some fancy dashes in your commandline! These are *not* the traditional -- dashes that software recognizes. You