Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass different parameters to mktemp on OSX #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 7 additions & 1 deletion src/temp.bash
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,13 @@ temp_make() {
template+='-XXXXXXXXXX'

local path
path="$(mktemp --directory --tmpdir="$BATS_TMPDIR" -- "$template" 2>&1)"

if [ "$(uname -s)" == "Darwin" ]; then
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't you want to detect which mktemp rather than the OS?

if mktemp --version >/dev/null 2>&1 ; then
    echo Using GNU mktemp
else
    echo Using BSD mktemp
fi

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to add my remote and implement that change, I currently don't have bats set up on my machine, and given that this PR is been ignored for about 3 months now, I don't think it's worth the effort to try to improve it.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've verified this works as expected on my mac.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given mac doesn't work at all, could we land this rather than bike shed it?

path="$(mktemp -d -- "${BATS_TMPDIR}${template}" 2>&1)"
else
path="$(mktemp -d --tmpdir="$BATS_TMPDIR" -- "$template" 2>&1)"
fi

if (( $? )); then
echo "$path" \
| batslib_decorate 'ERROR: temp_make' \
Expand Down