( I added a keyword :SHOWING to allow this to be used for both SYS:CALL-SYSTEM and SYS:CALL-SYSTEM-SHOWING-OUTPUT)
;; SAFE-CALL-SYSTEM - fixes a bug in LWM that prevents proper
;; character set translation of extended chars in filenames, making a
;; straightforward CALL-SYSTEM fail when it should otherwise succeed.
;;
;; DM/RAL 02/17 (LWM 7.0)
(defmethod safe-call-system ((v vector) &rest args &key &allow-other-keys)
(apply #'safe-call-system (coerce v 'list) args))
(defmethod safe-call-system ((lst list) &rest args &key &allow-other-keys)
(apply #'safe-call-system (format nil "~{~A ~}" lst) args))
(defmethod safe-call-system ((cmd string) &rest args &key showing &allow-other-keys)
(let ((syscmd (if showing
#'sys:call-system-showing-output
#'sys:call-system)))
(remf args :showing)
(if (some (lambda (c)
(> (char-code c) 127))
cmd)
(let ((scrfname (hcl:create-temp-file :directory "/tmp/")))
(with-open-file (s scrfname
:direction :output
:if-exists :supersede
:external-format '(:UTF-8 :eol-style :lf))
(write-line cmd s))
(unwind-protect
(apply syscmd (list "/bin/sh" (namestring scrfname)) args)
(delete-file scrfname)))
;; else
(apply syscmd cmd args))
))
- DM
Thank you Martin! That worked!!
- DM
On Feb 14, 2017, at 04:00, Martin Simmons <martin@lispworks.com> wrote:
The problem is that SYS:CALL-SYSTEM doesn't convert its arguments into the
correct external format.
You could try writing the command into a temporary file (opened with
:external-format :utf-8 probably) and then use
sys:call-system (list "/bin/sh" temp-file)
--
Martin Simmons
LispWorks Ltd
http://www.lispworks.com/
_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.comhttp://www.lispworks.com/support/lisp-hug.html