[Bps-public-commit] Shipwright branch, master, updated. e5201f0742ac7f719437bbe99dfc1f1af0dbed8a

sunnavy at bestpractical.com sunnavy at bestpractical.com
Sun Aug 9 22:53:22 EDT 2009


The branch, master has been updated
       via  e5201f0742ac7f719437bbe99dfc1f1af0dbed8a (commit)
      from  82b83c6dd84d0d307cc6ba65fb8bc1787c2d4593 (commit)

Summary of changes:
 lib/Shipwright/Manual/ENV.pod |    4 ++++
 lib/Shipwright/Util.pm        |   10 +++++++++-
 2 files changed, 13 insertions(+), 1 deletions(-)

- Log -----------------------------------------------------------------
commit e5201f0742ac7f719437bbe99dfc1f1af0dbed8a
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Aug 10 10:53:13 2009 +0800

    let's use HOME env

diff --git a/lib/Shipwright/Manual/ENV.pod b/lib/Shipwright/Manual/ENV.pod
index 6813caa..a465303 100644
--- a/lib/Shipwright/Manual/ENV.pod
+++ b/lib/Shipwright/Manual/ENV.pod
@@ -10,6 +10,10 @@ Introduce ENV variables Shipwright makes use of.
 
 =over 4
 
+=item HOME
+
+user's home directory, e.g. /home/joe
+
 =item SHIPWRIGHT_MAKE
 
     path of 'make' cmd, default value is 'make' on UNIX
diff --git a/lib/Shipwright/Util.pm b/lib/Shipwright/Util.pm
index ff3cc73..1e45fb5 100644
--- a/lib/Shipwright/Util.pm
+++ b/lib/Shipwright/Util.pm
@@ -189,7 +189,15 @@ return current user's home directory
 =cut
 
 sub user_home {
-    return (getpwuid $<)[7];
+    return $ENV{HOME} if $ENV{HOME};
+
+    my $home = eval { (getpwuid $<)[7] };
+    if ( $@ ) {
+        confess "can't find user's home, please set it by env HOME";    
+    }
+    else {
+        return $home;
+    }
 }
 
 =head2 shipwright_user_root

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list