File tree 1 file changed +26
-11
lines changed
1 file changed +26
-11
lines changed Original file line number Diff line number Diff line change @@ -151,26 +151,41 @@ verbose()
151
151
message " Swift/T"
152
152
153
153
# Handle temp file creation across platforms
154
- # Always has .SUFFIX somewhere
154
+ # Always has .SUFFIX somewhere, preferably at the end
155
155
make_temp ()
156
156
{
157
157
local SUFFIX=$1
158
158
local PROGRAM_DIR=$2
159
159
local NAME=$3
160
- # Linux:
161
- MKTEMP_VERSION=$( mktemp -V | awk ' {print $NF;exit}' )
162
- if (( ${MKTEMP_VERSION} > 2 ))
160
+ local MKTEMP_TYPE=" "
161
+ local SUFFIX_ARG=" "
162
+
163
+ # Attempt to determine mktemp version
164
+ # Mac mktemp does not support -V
165
+ if mktemp -V >& /dev/null
166
+ then
167
+ # Linux:
168
+ MKTEMP_VERSION=$( mktemp -V | awk ' {print $NF;exit}' )
169
+ if (( ${MKTEMP_VERSION} > 2 ))
170
+ then
171
+ MKTEMP_TYPE=" Linux"
172
+ else
173
+ MKTEMP_TYPE=" BSD"
174
+ fi
175
+ else
176
+ MKTEMP_TYPE=" Mac"
177
+ fi
178
+
179
+ if [[ ${MKTEMP_TYPE} == " Linux" ]]
163
180
then
164
- # Modern mktemp. .tic at the end.
165
- local SUFFIX_ARG
166
- SUFFIX_ARG=( --suffix .${SUFFIX} )
181
+ # Modern mktemp. .tic at the end.
182
+ SUFFIX_ARG=( --suffix .${SUFFIX} )
167
183
else
168
- # Old (BSD?) mktemp. .SUFFIX. will be in the middle of the name
169
- local SUFFIX_ARG=" "
170
- NAME=${NAME} .${SUFFIX}
184
+ # Old (BSD?) mktemp. .SUFFIX. will be in the middle of the name
185
+ NAME=${NAME} .${SUFFIX}
171
186
fi
187
+
172
188
mktemp ${SUFFIX_ARG} ${PROGRAM_DIR} /swift-t-${NAME} .XXX
173
- # TODO: Mac?
174
189
}
175
190
176
191
DELETE_PROGRAM_SWIFT=0
You can’t perform that action at this time.
0 commit comments