Permalink
Browse files

Fix parsing of target paths in all commands.

  • Loading branch information...
1 parent a7a2315 commit d48cbcb5a8fc3c399f6117287a3f2fd3a2ca434b @jteeuwen committed Nov 16, 2012
Showing with 18 additions and 7 deletions.
  1. +5 −0 dcpu-asm/main.go
  2. +1 −2 dcpu-deps/main.go
  3. +10 −1 dcpu-emu/main.go
  4. +1 −2 dcpu-link/main.go
  5. +1 −2 dcpu-list/main.go
View
@@ -47,6 +47,11 @@ func parseArgs() ([]string, asm.AsmFlags) {
targets := path.Expand(arg)
+ if len(targets) == 0 {
+ fmt.Fprintf(os.Stderr, "Missing target path.\n")
+ os.Exit(1)
+ }
+
var flags asm.AsmFlags
elem := strings.Split(*flagstr, ",")
View
@@ -57,9 +57,8 @@ func parseArgs() []string {
}
targets := path.Expand(arg)
-
if len(targets) == 0 {
- fmt.Fprintf(os.Stderr, "Missing link targets.\n")
+ fmt.Fprintf(os.Stderr, "Missing target path.\n")
os.Exit(1)
}
View
@@ -90,15 +90,24 @@ func parseArgs() *cpu.CPU {
}
targets := path.Expand(arg)
+ if len(targets) == 0 {
+ fmt.Fprintf(os.Stderr, "Invalid target path: %q\n", arg)
+ os.Exit(1)
+ }
+
target = path.Bin(targets[0])
+ if len(target) == 0 {
+ fmt.Fprintf(os.Stderr, "Invalid target path: %q\n", arg)
+ os.Exit(1)
+ }
// Create the CPU.
c := cpu.New()
c.ClockSpeed = time.Millisecond / 100
err := loadBinary(c)
if err != nil {
- fmt.Fprintf(os.Stderr, "Load binary: %s\n", err)
+ fmt.Fprintf(os.Stderr, "Load binary: %s.\n", err)
}
return c
View
@@ -43,9 +43,8 @@ func parseArgs() []string {
}
targets := path.Expand(arg)
-
if len(targets) == 0 {
- fmt.Fprintf(os.Stderr, "Missing link targets.\n")
+ fmt.Fprintf(os.Stderr, "Missing target path.\n")
os.Exit(1)
}
View
@@ -46,9 +46,8 @@ func parseArgs() []string {
}
targets := path.Expand(arg)
-
if len(targets) == 0 {
- fmt.Fprintf(os.Stderr, "Missing link targets.\n")
+ fmt.Fprintf(os.Stderr, "Missing target path.\n")
os.Exit(1)
}

0 comments on commit d48cbcb

Please sign in to comment.