Subject: | [PATCH] Use IPC::Cmd to find the default editors (android support) |
By using IPC::Cmd::can_run, the attached patch adds support for systems where vi or ed may exists, but not in /usr/bin/; although realistically, it's really just tog et the module working on Android.
Looking at the other issues for this module, I think that adding 'notepad' and 'notepad.exe' to the map that this patch introduces might help Windows users.
Subject: | 0001-use-IPC-Cmd-can_run-to-locale-default-editors.patch |
From e310d2097e9f2e1241829c68b68746e00aef5379 Mon Sep 17 00:00:00 2001
From: Brian Fraser <fraserbn@gmail.com>
Date: Wed, 30 Jul 2014 22:27:52 +0200
Subject: [PATCH] use IPC::Cmd::can_run to locale default editors
This is required for systems that have, say, vi, but
in a non-standard location; for example, Android comes
with vi under /system/bin/vi
---
Makefile.PL | 1 +
lib/Proc/InvokeEditor.pm | 4 +++-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/Makefile.PL b/Makefile.PL
index b421069..c798be7 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -9,6 +9,7 @@ WriteMakefile(
'Test::More' => 0.08,
'Carp::Assert' => 0.11,
'File::Spec' => 0.82,
+ 'IPC::Cmd' => 0,
}, # e.g., Module::Name => 1.1
'dist' => {
'COMPRESS' => 'gzip -9f',
diff --git a/lib/Proc/InvokeEditor.pm b/lib/Proc/InvokeEditor.pm
index 3c22f8e..9f03efa 100644
--- a/lib/Proc/InvokeEditor.pm
+++ b/lib/Proc/InvokeEditor.pm
@@ -5,6 +5,7 @@ use warnings;
use File::Temp qw(tempfile);
use File::Spec;
+use IPC::Cmd qw(can_run);
use Carp::Assert;
use Fcntl;
File::Temp->safe_level( File::Temp::HIGH );
@@ -35,7 +36,8 @@ use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK @EXPORT $VERSION
$VERSION = '1.06';
@DEFAULT_EDITORS = ( $ENV{'VISUAL'}, $ENV{'EDITOR'}, '/usr/bin/vi',
- '/bin/vi', '/bin/ed'
+ '/bin/vi', '/bin/ed',
+ map({ can_run($_) } qw(vi ed))
);
sub new {
--
1.7.12.4 (Apple Git-37)