Skip to content

Commit

Permalink
Support non-Coreutils mktemp
Browse files Browse the repository at this point in the history
  • Loading branch information
jhs committed Mar 19, 2010
1 parent 9907d31 commit 9aa1b85
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,18 @@ here=$( pwd )
trap 'return_here' INT TERM
return_here () {
cd "$here"
[ -d "$build_tmp" ] && rm -rf "$build_tmp"
[ -d "$workdir" ] && rm -rf "$workdir"
}

in_temp_dir () {
cmd="$1"; shift
workdir=$( mktemp --tmpdir -d "$cmd.XXXXXX" )
template="$cmd.XXXXXX"
if mktemp -V | grep --quiet coreutils; then
workdir=$( mktemp --tmpdir -d "$template" )
else
workdir=$( mktemp -t -d "$template" )
fi

trap 'return_here' INT TERM
"$cmd" "$@"
return_here
Expand Down Expand Up @@ -125,7 +131,7 @@ confirm_build rake "$build/bin/rake" 0.8.7 || return 1

# Clean up if everything went okay. (If it didn't go okay, well, you're on your own.)
unset build
unset build_tmp
unset workdir
unset cmd
unset failed
unset gems_src
Expand Down

0 comments on commit 9aa1b85

Please sign in to comment.