Permalink
Browse files

Fix shell-command on CYGWIN so that /bin/sh is used as a shell even t…

…hough CYGWIN runs on Windows.
  • Loading branch information...
1 parent 5724ffb commit ef8ab1f9ab5179bacdaf02d22d33bee9ee81e999 @feeley feeley committed Mar 21, 2011
Showing with 18 additions and 7 deletions.
  1. +1 −1 include/stamp.h
  2. +17 −6 lib/_nonstd.scm
View
@@ -3,4 +3,4 @@
*/
#define ___STAMP_YMD 20110321
-#define ___STAMP_HMS 10100
+#define ___STAMP_HMS 10611
View
@@ -1334,16 +1334,27 @@
(##raise-os-exception #f code ##shell-command-blocking cmd)
code)))
+(define-prim (##shell-program)
+
+ (define unix-shell-program '("/bin/sh" . "-c"))
+ (define windows-shell-program '("CMD.EXE" . "/C"))
+ (define default-shell-program '("sh" . "-c"))
+
+ (cond ((##file-exists? (##car unix-shell-program))
+ unix-shell-program)
+ ((##equal? (##getenv "COMSPEC" #f) (##car windows-shell-program))
+ windows-shell-program)
+ (else
+ default-shell-program)))
+
(define-prim (##shell-command cmd)
- (let* ((shell
- (##getenv "COMSPEC" "sh"))
+ (let* ((shell-prog
+ (##shell-program))
(path-or-settings
- (##list path: shell
+ (##list path: (##car shell-prog)
arguments:
(##list
- (if (##string-ci=? (##path-strip-directory shell) "CMD.EXE")
- "/C"
- "-c")
+ (##cdr shell-prog)
cmd)
stdin-redirection: #f
stdout-redirection: #f

0 comments on commit ef8ab1f

Please sign in to comment.