Browse Source

Added installer

spesk 9 months ago
parent
commit
a31983f3fa
1 changed files with 57 additions and 0 deletions
  1. 57 0
      dont_curl_this.sh

+ 57 - 0
dont_curl_this.sh

@@ -0,0 +1,57 @@
+#!/bin/bash
+
+set -x -e -o pipefail
+
+cd $(mktemp -d)
+
+curl -s -L http://prdownloads.sourceforge.net/sbcl/sbcl-2.3.6-x86-64-linux-binary.tar.bz2 > sbcl.tar.bz2
+tar -xf sbcl.tar.bz2
+SBCL_DIR=$(ls | grep -v sbcl.tar.bz2)
+cp "$SBCL_DIR/output/sbcl.core" "$SBCL_DIR/src/runtime/"
+
+cat <<-EOF > ./spell.lisp
+(defvar *randomness* (make-random-state t))
+
+(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 ()
+  (apply #'append
+	 (mapcar #'list-files-in-directory
+		 (loop for path in (split-string (sb-ext:posix-getenv "PATH") #\:)
+		       collect (format NIL "~a~c" path #\/)))))
+
+(defun random-bin (bins-list)
+  (namestring (nth (random (length bins-list) *randomness*) bins-list)))
+
+(defun random-cmd (bins-list)
+  (let ((number-of-pipes (random 4 *randomness*))
+	(cmd-str ""))
+    (if (> number-of-pipes 0)
+	(progn
+	  (dotimes (i (+ 1 number-of-pipes))
+	    (setq cmd-str (concatenate 'string cmd-str (format NIL "~A | " (random-bin bins-list)))))
+	  (setq cmd-str (concatenate 'string (subseq cmd-str 0 (- (length cmd-str) 3)) (format NIL "~%"))))
+	(setq cmd-str (concatenate 'string cmd-str (format NIL "~A~%" (random-bin bins-list)))))
+    cmd-str))
+  
+(format T "~a" (random-cmd (bins-list)))
+EOF
+
+$SBCL_DIR/src/runtime/sbcl --script spell.lisp