Use ctx.Fatalln instead of log.Fatalln for absolute path errors

log.Fatalln calls os.Exit, which skips deferred functions and
leaves the console with the cursor disabled.  Use ctx.Fatalln
instead, which uses a panic to exit and calls the deferred
function to restore the cursor.

Test: DIST_DIR=/tmp/\test\ foo m dist
Change-Id: Ie92297075e37c171d5ba48848a0ddb19652b051c
This commit is contained in:
Colin Cross 2019-09-23 15:52:40 -07:00
parent c0b9f6b9d2
commit 1f6faeb50f

View file

@ -16,7 +16,6 @@ package build
import ( import (
"io/ioutil" "io/ioutil"
"log"
"os" "os"
"path/filepath" "path/filepath"
"runtime" "runtime"
@ -189,27 +188,27 @@ func NewConfig(ctx Context, args ...string) Config {
checkTopDir(ctx) checkTopDir(ctx)
if srcDir := absPath(ctx, "."); strings.ContainsRune(srcDir, ' ') { if srcDir := absPath(ctx, "."); strings.ContainsRune(srcDir, ' ') {
log.Println("You are building in a directory whose absolute path contains a space character:") ctx.Println("You are building in a directory whose absolute path contains a space character:")
log.Println() ctx.Println()
log.Printf("%q\n", srcDir) ctx.Printf("%q\n", srcDir)
log.Println() ctx.Println()
log.Fatalln("Directory names containing spaces are not supported") ctx.Fatalln("Directory names containing spaces are not supported")
} }
if outDir := ret.OutDir(); strings.ContainsRune(outDir, ' ') { if outDir := ret.OutDir(); strings.ContainsRune(outDir, ' ') {
log.Println("The absolute path of your output directory ($OUT_DIR) contains a space character:") ctx.Println("The absolute path of your output directory ($OUT_DIR) contains a space character:")
log.Println() ctx.Println()
log.Printf("%q\n", outDir) ctx.Printf("%q\n", outDir)
log.Println() ctx.Println()
log.Fatalln("Directory names containing spaces are not supported") ctx.Fatalln("Directory names containing spaces are not supported")
} }
if distDir := ret.DistDir(); strings.ContainsRune(distDir, ' ') { if distDir := ret.DistDir(); strings.ContainsRune(distDir, ' ') {
log.Println("The absolute path of your dist directory ($DIST_DIR) contains a space character:") ctx.Println("The absolute path of your dist directory ($DIST_DIR) contains a space character:")
log.Println() ctx.Println()
log.Printf("%q\n", distDir) ctx.Printf("%q\n", distDir)
log.Println() ctx.Println()
log.Fatalln("Directory names containing spaces are not supported") ctx.Fatalln("Directory names containing spaces are not supported")
} }
// Configure Java-related variables, including adding it to $PATH // Configure Java-related variables, including adding it to $PATH