File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed
Sources/swift-sh/OptionGroups Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -41,15 +41,15 @@ final class BuildAndRunOptions : ParsableArguments {
4141 ) :
4242 ScriptSource ( content: scriptPathOrContent, fileManager: fm, logger: logger)
4343 )
44- let scriptPath = try scriptSource. scriptPath? . 0 ?! InternalError ( message: " scriptPath is nil " )
45- guard scriptSource. scriptPath? . isTmp == true else { throw InternalError ( message: " scriptPath is not tmp " ) }
4644 let cleanup = {
47- /* Notes:
48- * We should probably also register a sigaction to remove the temporary file in case of a terminating signal.
49- * Or we could remove the file just after launching swift with it (to be tested). */
50- let p = scriptPath. string
51- do { try fm. removeItem ( atPath: p) }
52- catch { logger. warning ( " Failed removing temporary file. " , metadata: [ " file-path " : " \( p) " , " error " : " \( error) " ] ) }
45+ if let scriptPath = scriptSource. scriptPath, scriptPath. isTmp {
46+ /* Notes:
47+ * We should probably also register a sigaction to remove the temporary file in case of a terminating signal.
48+ * Or we could remove the file just after launching swift with it (to be tested). */
49+ let p = scriptPath. 0 . string
50+ do { try fm. removeItem ( atPath: p) }
51+ catch { logger. warning ( " Failed removings temporary file. " , metadata: [ " file-path " : " \( p) " , " error " : " \( error) " ] ) }
52+ }
5353 }
5454
5555 let scriptPathForSwift : String
You can’t perform that action at this time.
0 commit comments