Created
March 14, 2009 14:31
-
-
Save southly/79081 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/opt/local/bin/sbcl --script | |
(write-line "Hello, World!") | |
;; --script オプションを付ける | |
;; version 1.0.22 以降 | |
;; http://www.sbcl.org/manual/Shebang-Scripts.html | |
;; http://www.sbcl.org/manual/Saving-a-Core-Image.html | |
;; http://www.sbcl.org/manual/Support-For-Unix.html | |
;; http://www.sbcl.org/manual/Quit.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/opt/local/bin/sbcl --script | |
(format *standard-output* "~{~A~^ ~}~%" (cdr *posix-argv*)) | |
;; スクリプトの引数は sb-ext:*posix-argv* にリストとして入っている | |
;; ただし、ひとつめは sbcl のパス |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/opt/local/bin/sbcl --script | |
(print *load-pathname*) | |
(print *load-truename*) | |
;; スクリプトファイルのパスは | |
;; - *load-pathname* | |
;; - *load-truename* | |
;; に入っている |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/opt/local/bin/sbcl --script | |
(format t "Read Line: ") | |
(force-output) | |
(format t "Input : ~A~%" (read-line *standard-input*)) | |
(terpri *standard-output*) | |
(write-line "stdout" *standard-output*) | |
(terpri *standard-output*) | |
(write-line "stderr" *error-output*) | |
;; *standard-input* : 標準入力 | |
;; *standard-output* : 標準出力 | |
;; *error-output* : 標準エラー出力 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/opt/local/bin/sbcl --script | |
(format t "Read Line: ") | |
(force-output) | |
(let ((n (parse-integer (read-line *standard-input*) :junk-allowed t))) | |
; (sb-ext:quit :recklessly-p t :unix-status n) | |
(sb-unix:unix-exit n) | |
) | |
;; exit status を指定したい場合は sb-unix:unix-exit を使用 | |
;; sb-ext:quit の :unix-status パラメータを使用する方法もあり |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment