From ad38e106431064d90a8089987963b1a59d243bc9 Mon Sep 17 00:00:00 2001
From: Vitaly Lipatov <lav@etersoft.ru>
Date: Thu, 23 Mar 2023 03:39:23 +0300
Subject: [PATCH] remove CURDIR to EPMCURDIR and export it without override

---
 bin/epm         |  4 ++--
 bin/epm-install | 10 +++++-----
 bin/epm-pack    |  4 ++--
 bin/epm-repack  |  4 ++--
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/bin/epm b/bin/epm
index 1086b1ed..bdb0cfed 100755
--- a/bin/epm
+++ b/bin/epm
@@ -19,10 +19,10 @@
 
 PROGDIR=$(dirname "$0")
 PROGNAME=$(basename "$0")
-CURDIR="$(pwd)"
+[ -n "$EPMCURDIR" ] || export EPMCURDIR="$(pwd)"
 CMDSHELL="/bin/sh"
 # TODO: pwd for ./epm and which for epm
-[ "$PROGDIR" = "." ] && PROGDIR="$CURDIR"
+[ "$PROGDIR" = "." ] && PROGDIR="$EPMCURDIR"
 if [ "$0" = "/dev/stdin" ] || [ "$0" = "sh" ] ; then
     PROGDIR=""
     PROGNAME=""
diff --git a/bin/epm-install b/bin/epm-install
index 608e7a21..92a870c8 100644
--- a/bin/epm-install
+++ b/bin/epm-install
@@ -328,7 +328,7 @@ epm_install_files()
 
             if [ -n "$download_only" ] ; then
                 echo
-                cp -v $files "$CURDIR"
+                cp -v $files "$EPMCURDIR"
                 return
             fi
 
@@ -384,7 +384,7 @@ epm_install_files()
 
             if [ -n "$download_only" ] ; then
                 echo
-                cp -v $files "$CURDIR"
+                cp -v $files "$EPMCURDIR"
                 return
             fi
 
@@ -439,7 +439,7 @@ epm_install_files()
 
             if [ -n "$download_only" ] ; then
                 echo
-                cp -v $files "$CURDIR"
+                cp -v $files "$EPMCURDIR"
                 return
             fi
 
@@ -485,7 +485,7 @@ epm_install_files()
     # check download_only before commands without repack supporting
     if [ -n "$download_only" ] ; then
         echo
-        cp -v $files "$CURDIR"
+        cp -v $files "$EPMCURDIR"
         return
     fi
 
@@ -735,7 +735,7 @@ epm_install()
     # save files before install and repack
     if [ -n "$direct" ] && [ -n "$download_only" ] ; then
         echo
-        cp -v $files "$CURDIR"
+        cp -v $files "$EPMCURDIR"
         return
     fi
 
diff --git a/bin/epm-pack b/bin/epm-pack
index 2252a097..3f148c6c 100644
--- a/bin/epm-pack
+++ b/bin/epm-pack
@@ -113,12 +113,12 @@ epm_pack()
             return
         fi
 
-        cp $packed_pkgs "$CURDIR"
+        cp $packed_pkgs "$EPMCURDIR"
         if [ -z "$quiet" ] ; then
             echo
             echo "Packed packages:"
             for i in $packed_pkgs ; do
-                echo "	$CURDIR/$(basename "$i")"
+                echo "	$EPMCURDIR/$(basename "$i")"
             done
         fi
     fi
diff --git a/bin/epm-repack b/bin/epm-repack
index f75b5b6c..636118e8 100644
--- a/bin/epm-repack
+++ b/bin/epm-repack
@@ -451,12 +451,12 @@ epm_repack()
     [ -z "$pkg_files" ] && info "Skip empty repack list" && return 22
 
     if __epm_repack $pkg_files && [ -n "$repacked_pkgs" ] ; then
-        cp $repacked_pkgs "$CURDIR"
+        cp $repacked_pkgs "$EPMCURDIR"
         if [ -z "$quiet" ] ; then
             echo
             echo "Adapted packages:"
             for i in $repacked_pkgs ; do
-                echo "	$CURDIR/$(basename "$i")"
+                echo "	$EPMCURDIR/$(basename "$i")"
             done
         fi
     fi
-- 
2.24.1