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 <alex.boutin@proton.me>
This commit is contained in:
Alex Boutin
2025-09-29 21:21:22 -04:00
committed by Stéphane Peter
parent 6abf2d818b
commit a5fbefce47
2 changed files with 16 additions and 1 deletions
+2
View File
@@ -17,6 +17,8 @@ USER_PWD="\$PWD"
export USER_PWD
ARCHIVE_DIR=\`dirname "\$0"\`
export ARCHIVE_DIR
ARCHIVE_NAME=\`basename "\$0"\`
export ARCHIVE_NAME
label="$LABEL"
script="$SCRIPT"
+14 -1
View File
@@ -3,6 +3,7 @@ set -eu
THIS="$(readlink -f "$0")"
THISDIR="$(dirname "${THIS}")"
SUT="$(dirname "${THISDIR}")/makeself.sh"
ARCHIVE_NAME="makeself-test.run"
setupTests() {
temp=`mktemp -d -t XXXXX`
@@ -11,7 +12,7 @@ setupTests() {
touch archive/file
# $SUT archive makeself-test.run "Test $1" declare -p "${1}"
$SUT archive makeself-test.run "Test $1" echo \\\"\${${1}}\\\"
$SUT archive "${ARCHIVE_NAME}" "Test $1" echo \\\"\${${1}}\\\"
}
testArchiveDir()
@@ -48,5 +49,17 @@ testUserPWD()
assertEquals "${actual_user_pwd}" "${ans}"
}
testArchiveName()
{
setupTests ARCHIVE_NAME
local ans="${temp}"$'/complicated\n dir\twith spaces'
mkdir -p "${ans}"
cd "${ans}"
actual_archive_name="$("${temp}/makeself-test.run" --quiet)"
assertEquals "${actual_archive_name}" "${ARCHIVE_NAME}"
}
# Load and run shUnit2.
source "./shunit2/shunit2"