Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/usr/local/buildpack/utils/linking.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# use this if custom env is required, creates a shell wrapper to /usr/local/bin
function shell_wrapper () {
local FILE
FILE="$(get_bin_path)/bin/${1}"
FILE="$(get_bin_path)/${1}"
check_command "$1"
cat > "$FILE" <<- EOM
#!/bin/bash
Expand All @@ -20,7 +20,8 @@ fi

${1} "\$@"
EOM
chmod +x "$FILE"
# make it writable for the owner and the group
chmod 775 "$FILE"
}

# use this for simple symlink to /usr/local/bin
Expand Down
17 changes: 13 additions & 4 deletions test/bash/linking.bats
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ teardown() {

@test "shell_wrapper" {

mkdir -p "${USER_HOME}/bin"
echo "#!/bin/bash\n\necho 'foobar'" > "${USER_HOME}/bin/foobar"
chmod +x "${USER_HOME}/bin/foobar"

run shell_wrapper
assert_failure
assert_output --partial "No defined"
Expand All @@ -70,8 +74,13 @@ teardown() {
assert_failure
assert_output --partial "No foo defined"

# cannot test, the function is broken
# run shell_wrapper ls
# assert_success
# assert_output --partial "No foo defined"
run shell_wrapper ls
assert_success
assert [ -f "${BIN_DIR}/ls" ]
assert [ $(stat --format '%a' "${BIN_DIR}/ls") -eq 775 ]

PATH="${USER_HOME}/bin":$PATH run shell_wrapper foobar
assert_success
assert [ -f "${BIN_DIR}/foobar" ]
assert [ $(stat --format '%a' "${BIN_DIR}/ls") -eq 775 ]
}