|
@@ -0,0 +1,33 @@
|
|
|
+#!/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)))
|
|
|
+
|
|
|
+(defun bins-list ()
|
|
|
+ (apply #'append
|
|
|
+ (mapcar #'uiop:directory-files
|
|
|
+ (loop for path in (split-sequence:split-sequence #\: (uiop:getenv "PATH"))
|
|
|
+ collect (format NIL "~a~c" path #\/)))))
|
|
|
+
|
|
|
+(defun random-bin (bins-list)
|
|
|
+ (nth (random (length bins-list)) bins-list))
|
|
|
+
|
|
|
+(defun random-cmd (bins-list)
|
|
|
+ (let ((number-of-pipes (random 4))
|
|
|
+ (cmd-str ""))
|
|
|
+ (if (> number-of-pipes 0)
|
|
|
+ (progn
|
|
|
+ (dotimes (i (+ 1 number-of-pipes))
|
|
|
+ (setf cmd-str (concatenate 'string cmd-str (format NIL "~A | " (random-bin bins-list)))))
|
|
|
+ (setf cmd-str (concatenate 'string (subseq cmd-str 0 (- (length cmd-str) 3)) (format NIL "~%"))))
|
|
|
+ (setf cmd-str (concatenate 'string cmd-str (format NIL "~A~%" (random-bin bins-list)))))
|
|
|
+ cmd-str))
|
|
|
+
|
|
|
+
|
|
|
+
|