|
@@ -1,18 +1,28 @@
|
|
-#!/usr/bin/sbcl --script
|
|
|
|
-
|
|
|
|
-(ql:quickload "uiop")
|
|
|
|
-(ql:quickload "split-sequence")
|
|
|
|
-
|
|
|
|
-;; (defvar *path* (uiop:getenv "PATH"))
|
|
|
|
-
|
|
|
|
-;; (defun file-is-executable-p (file-path)
|
|
|
|
-;; (let ((oct-mode (mod (parse-integer (format NIL "~o" (sb-posix:stat-mode (sb-posix:stat file-path)))) 1000)))
|
|
|
|
-;; (if (> oct-mode 711) T NIL)))
|
|
|
|
|
|
+;;#!/usr/bin/sbcl --script
|
|
|
|
+
|
|
|
|
+(defun split-string (string delimiter)
|
|
|
|
+ (loop with len = (length string)
|
|
|
|
+ with start = 0
|
|
|
|
+ for end = (position delimiter string :start start)
|
|
|
|
+ for substr = (if end
|
|
|
|
+ (subseq string start end)
|
|
|
|
+ (subseq string start))
|
|
|
|
+ while end
|
|
|
|
+ append (list substr)
|
|
|
|
+ do (setf start (1+ end))
|
|
|
|
+ until (= end len)))
|
|
|
|
+
|
|
|
|
+(defun list-files-in-directory (directory-path)
|
|
|
|
+ (let* ((files (directory (merge-pathnames "*.*" (pathname directory-path))))
|
|
|
|
+ (directory-pathname (pathname directory-path)))
|
|
|
|
+ (mapcar #'(lambda (file)
|
|
|
|
+ (merge-pathnames (pathname file) directory-pathname))
|
|
|
|
+ files)))
|
|
|
|
|
|
(defun bins-list ()
|
|
(defun bins-list ()
|
|
(apply #'append
|
|
(apply #'append
|
|
- (mapcar #'uiop:directory-files
|
|
|
|
- (loop for path in (split-sequence:split-sequence #\: (uiop:getenv "PATH"))
|
|
|
|
|
|
+ (mapcar #'list-files-in-directory
|
|
|
|
+ (loop for path in (split-string (sb-ext:posix-getenv "PATH") #\:)
|
|
collect (format NIL "~a~c" path #\/)))))
|
|
collect (format NIL "~a~c" path #\/)))))
|
|
|
|
|
|
(defun random-bin (bins-list)
|
|
(defun random-bin (bins-list)
|
|
@@ -29,5 +39,5 @@
|
|
(setf cmd-str (concatenate 'string cmd-str (format NIL "~A~%" (random-bin bins-list)))))
|
|
(setf cmd-str (concatenate 'string cmd-str (format NIL "~A~%" (random-bin bins-list)))))
|
|
cmd-str))
|
|
cmd-str))
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+;; (format T "~A" (random-cmd (bins-list)))
|
|
|
|
+(format T "~A" (random-bin (bins-list)))
|