setup/command-name: drop ".exe" in short form

This commit is contained in:
Matthew Flatt 2013-12-24 10:57:14 -06:00
parent 1f2012a106
commit f5cfcfecfe
2 changed files with 11 additions and 4 deletions

View File

@ -83,7 +83,8 @@ Returns a string that identifies the current command. When
short name of the @exec{raco} executable followed by a space and the
command name. Otherwise, it is the short name of the current
executable, as determined by stripping the path from the result of
@racket[(find-system-path 'run-file)].
@racket[(find-system-path 'run-file)]. In either case, on Windows, an
@filepath{.exe} extension is removed from the executable name.
The result of this function is suitable for use with
@racket[command-line]. For example, the @exec{decompile} tool parses

View File

@ -21,7 +21,13 @@
(let-values ([(p) (find-system-path 'run-file)]
[(n) (current-command-name)])
(let-values ([(base name dir?) (split-path p)])
(if n
(format "~a ~a" name n)
(path->string name)))))))
(let-values ([(name) (if (eq? (system-type) 'windows)
(string->path-element
(regexp-replace #rx"(?i:[.]exe)$"
(path-element->string name)
""))
name)])
(if n
(format "~a ~a" name n)
(path->string name))))))))