Skip to content

Commit 2a9b648

Browse files
committed
feat(variable): Access archive name from script
Export `ARCHIVE_NAME` to give start script access to the name of the archive Signed-off-by: Alex Boutin <[email protected]>
1 parent 55d96ab commit 2a9b648

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

makeself-header.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ USER_PWD="\$PWD"
1717
export USER_PWD
1818
ARCHIVE_DIR=\`dirname "\$0"\`
1919
export ARCHIVE_DIR
20+
ARCHIVE_NAME=\`basename "\$0"\`
21+
export ARCHIVE_NAME
2022
2123
label="$LABEL"
2224
script="$SCRIPT"

test/variabletest

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set -eu
33
THIS="$(readlink -f "$0")"
44
THISDIR="$(dirname "${THIS}")"
55
SUT="$(dirname "${THISDIR}")/makeself.sh"
6+
ARCHIVE_NAME="makeself-test.run"
67

78
setupTests() {
89
temp=`mktemp -d -t XXXXX`
@@ -11,7 +12,7 @@ setupTests() {
1112
touch archive/file
1213

1314
# $SUT archive makeself-test.run "Test $1" declare -p "${1}"
14-
$SUT archive makeself-test.run "Test $1" echo \\\"\${${1}}\\\"
15+
$SUT archive "${ARCHIVE_NAME}" "Test $1" echo \\\"\${${1}}\\\"
1516
}
1617

1718
testArchiveDir()
@@ -48,5 +49,17 @@ testUserPWD()
4849
assertEquals "${actual_user_pwd}" "${ans}"
4950
}
5051

52+
testArchiveName()
53+
{
54+
setupTests ARCHIVE_NAME
55+
local ans="${temp}"$'/complicated\n dir\twith spaces'
56+
mkdir -p "${ans}"
57+
cd "${ans}"
58+
59+
actual_archive_name="$("${temp}/makeself-test.run" --quiet)"
60+
61+
assertEquals "${actual_archive_name}" "${ARCHIVE_NAME}"
62+
}
63+
5164
# Load and run shUnit2.
5265
source "./shunit2/shunit2"

0 commit comments

Comments
 (0)