#!/usr/bin/env openlisp -shell
;;;; Title:     testsh.lsp
;;;; Author:    C. Jullien
;;;; License:   New BSD license
;;;; CVS:       $Id: testsh.lsp,v 1.5 2013/06/15 06:24:34 jullien Exp $

;;;
;;; This is a simple test to show OpenLisp used as a shell.
;;;

;;;
;;; On unix, set executable bit using chmod.
;;; On Windows, run: "openlisp -shell testsh.lsp"
;;;

(defun type-name (arg)
   (class-name (class-of (or (ignore-errors (parse-number arg)) arg))))

(cond
      ((= $# 0)
       (format (error-output) "Usage: ~A arg [arg...]~%" $0)
       (end 1))
      (t
       (format t ";; OpenLisp v~a~%" (version))
       (format t ";; Calling ~a with ~a argument(s).~%" $0 $#)
       (format t "~%")
       (format t ";; 1) as vector: ~a~%" $*)
       (for ((i 1 (+ i 1)))
	    ((> i $#))
	    (format t ";; arg~D: ~S ~S~%" i $i (type-name $i)))
       (format t "~%")
       (format t ";; 2) as list: ~a~%" $@)
       (dolist (x $@)
       	       (format t ";; ~S ~S~%" x (type-name x)))))