From 662fd84edabb3f30e4f6d9df0dda43a89bc25298 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Mon, 10 Apr 2017 08:13:35 -0600 Subject: [PATCH] raco: fix command name selection by prefix Repairs a problem with 409321c03b. Merge to v6.9 --- pkgs/racket-test-extra/tests/raco/prefix.rkt | 15 +++++++++++++++ racket/collects/raco/raco.rkt | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 pkgs/racket-test-extra/tests/raco/prefix.rkt diff --git a/pkgs/racket-test-extra/tests/raco/prefix.rkt b/pkgs/racket-test-extra/tests/raco/prefix.rkt new file mode 100644 index 0000000000..ed918299c5 --- /dev/null +++ b/pkgs/racket-test-extra/tests/raco/prefix.rkt @@ -0,0 +1,15 @@ +#lang racket/base +(require compiler/find-exe + racket/system) + +;; Make sure that `raco` recognizes unambiguous command prefixes. +;; This test assumes that "pk" will unambiguously refer to "pkg". + +(define o (open-output-bytes)) +(parameterize ([current-output-port o]) + (system* (find-exe) + "-N" "raco" + "-l-" "raco" + "pk")) +(unless (regexp-match? #rx"raco pkg install" (get-output-bytes o)) + (error "expected output from `raco pkg`")) diff --git a/racket/collects/raco/raco.rkt b/racket/collects/raco/raco.rkt index 9bb08b102e..8fd684b299 100644 --- a/racket/collects/raco/raco.rkt +++ b/racket/collects/raco/raco.rkt @@ -52,7 +52,7 @@ [tool (and (pair? cmdline) (or (hash-ref tools (car cmdline) #f) (and (= (hash-count prefix-tools) 1) - (hash-ref tools (car cmdline) #f))))] + (car (hash-values prefix-tools)))))] [ambiguous? (> (hash-count prefix-tools) 1)] [show-all? (cond