shithub: sl

Download patch

ref: 2bfb708683daed9f1b038614ee016938f3c0ef7e
parent: 04d8c503113e00b81643a2b99ae1266b63f81a6c
author: spew <spew@cbza.org>
date: Thu Mar 20 17:19:00 EDT 2025

slmain: add interactive flag to force entry into repl

--- a/boot/sl.boot
+++ b/boot/sl.boot
@@ -81,18 +81,14 @@
 gin or => 1arg-lambda? caddr caadr let if cddr #:g20) cond-clauses->if)))  do #fn("z21<2071052207205220230522425268827872829e12:1=51522829e12:82512825e18:52e153e4e3e2e12825e18952e3:" #(#fn(map)
   car cadr #fn("n170051B38071061:0<:" #(cddr caddr)) letrec #:g337 λ if #fn(nconc) begin #fn(copy-list)))  mark-label #fn("n22002122e21e4:" #(emit
   quote label))  with-bindings #fn("z12071052207205220230522425e12076888653e12720288687535129242:e12715152242:e127202;8688535152e3e164:" #(#fn(map)
-caddr)) letrec #:g337 λ if #fn(nconc) begin #fn(copy-list)))  mark-label #fn("n22002122e21e4:" #(emit
+caddr)) letrec #:g337 λ if #fn(nconc) begin #fn(copy-list)))  mark-label #fn("n22002122e21e4:" #(emit
 e12076888653e12720288687535129242:e12715152242:e127202;8688535152e3e164:" #(#fn(map)
   car cadr #fn("n12060:" #(#fn(gensym))) #fn(nconc) let list #fn(copy-list)
   #fn("n22001e3:" #(set!)) unwind-protect begin #fn("n22001e3:" #(set!))))  let #fn("z1q0R3B00?641<?041=?1@30q42021e12223052e124151532225052863C0268687e2e186e3@408788P:" #(#fn(nconc)
   λ #fn(map) #fn("n10B3500<:0:" #()) #fn(copy-list)
   #fn("n10B3500T:7060:" #(void)) letrec))  bcode:code #fn("n1200Ee3:" #(aref))  make-label #fn("n120e1:" #(gensym))  bcode:cenv #fn("n1200r3e3:" #(aref))  > #fn("z12021e12273151510e163:" #(#fn(nconc)
-(void)) letrec))  bcode:code #fn("n1200Ee3:" #(aref))  make-label #fn("n120e1:" #(gensym))  bcode:cenv #fn("n1200r3e3:" #(aref))  > #fn("z12021e12273151510e163:" #(#fn(nconc)
-  < #fn(copy-list) reverse!))  when #fn("z1200211Pqe4:" #(if begin))  quasiquote #fn("n1700E62:" #(bq-process))  help #fn("O100010002000W1000J7071?14720235272024q5386;J504873Y0251260e22687e2e327862886e229e1e42:e1e4:782;05240R3@00ZJ;0782<51@30q47960:" #(#(:print-header
-  0) help-print-header getprop *doc* *funvars* begin quote when princ newline void "no help for "
-  " (undefined)"))  defstruct #fn("O10005000*///W1000J7071?14W2000J60D?24W3000J60D?34W4000J60q?44W5000J60q?54z6IIb;228;230>1_5142224?<5142586<51;360486<8=;360486=;J50486268>5127288>528<8>512912:5285;J:042902:5283;3\\0483H;3M0483DQ;3:04292;052;J504838AP;J5048382;36040e184;J:042<02=522>2?e12@8C2Ae22B8B2Ae22C2D2E8Ee2e22F2G2AEe32E0e2e3e32H2I2Ae2268E518?Me3e4e3e12J8=2K2E0e28=e3e3e18D3X02@8D2>1e12>2Ee12L8E5152e12L8@5153e3@30qe12L7M2N8;8A8@8F8C8E0>78?525165:" #(#(NIL
-  NIL :named 1 :conc-name 3 :type 0 NIL NIL NIL NIL NIL NIL :predicate 4 NIL NIL NIL NIL NIL NIL
-  :constructor 2) vec #0# #fn("n17005121220A>28552485:" #(cddr #fn(for-each)
+oid)) letrec))  bcode:code #fn("n1200Ee3:" #(aref))  make-label #fn("n120e1:" #(gensym))  bcode:cenv #fn("n1200r3e3:" #(aref))  > #fn("z12021e12273151510e163:" #(#fn(nconc)
+  < #fn(copy-list) reverse!))  when #fn("z1200211Pqe4:" #(if begin))  quasiquote #fn("n1700E62:" #(bq-process))  help #fn("O100010002000W1000J7071?14720235272024q5386;J504873Y0251260e22687e2e327862886e229e1e42:e1e4:782;05240R3@00ZJ;0782<51@30q47960:" #(#(:print-header
 0*///W1000J7071?14W2000J60D?24W3000J60D?34W4000J60q?44W5000J60q?54z6IIb;228;230>1_5142224?<5142586<51;360486<8=;360486=;J50486268>5127288>528<8>512912:5285;J:042902:5283;3\\0483H;3M0483DQ;3:04292;052;J504838AP;J5048382;36040e184;J:042<02=522>2?e12@8C2Ae22B8B2Ae22C2D2E8Ee2e22F2G2AEe32E0e2e3e32H2I2Ae2268E518?Me3e4e3e12J8=2K2E0e28=e3e3e18D3X02@8D2>1e12>2Ee12L8E5152e12L8@5153e3@30qe12L7M2N8;8A8@8F8C8E0>78?525165:" #(#(NIL
   NIL :named 1 :conc-name 3 :type 0 NIL NIL NIL NIL NIL NIL :predicate 4 NIL NIL NIL NIL NIL NIL
   :constructor 2) vec #0# #fn("n17005121220A>28552485:" #(cddr #fn(for-each)
--- a/src/plan9/lsd.lsp
+++ b/src/plan9/lsd.lsp
@@ -1,4 +1,4 @@
-#!/bin/sl
+#!/bin/sl -i
 
 (defstruct reg name type addr size)
 (defstruct symbol name type addr)
@@ -314,5 +314,3 @@
 (let* ((proc (cadr *argv*))
        (pid (str->num proc)))
   (if pid (lsd pid) (lsd proc)))
-
-(repl)
--- a/src/slmain.c
+++ b/src/slmain.c
@@ -74,6 +74,7 @@
 slmain(const u8int *boot, int bootsz, int argc, char **argv)
 {
 	usize heapsize = HEAP_SIZE0, stacksize = STACK_SIZE0;
+	sl_v interactive = sl_nil;
 	char *e;
 
 	nan_init();
@@ -90,6 +91,9 @@
 		stacksize = strtoull(EARGF(usage()), &e, 0);
 		sizesuffix(&stacksize, *e);
 		break;
+	case 'i':
+		interactive = sl_t;
+		break;
 	case 'h':
 		usage();
 	default:
@@ -130,7 +134,7 @@
 			ios_close(&s);
 			ios_free(&s);
 			sl_free_gc_handles(1);
-			sl_applyn(1, sym_value(mk_sym("__start", false)), args);
+			sl_applyn(2, sym_value(mk_sym("__start", false)), args, interactive);
 			r = 0;
 		}
 	}
--- a/src/system.lsp
+++ b/src/system.lsp
@@ -1397,19 +1397,19 @@
                    (("plan9") "lib/slrc")
                    (else ".slrc")))
          (fname (and home (str home *directory-separator* rcpath))))
-    (when (and fname (path-exists? fname))
-      (load fname))))
+    (and fname (path-exists? fname) (load fname))))
 
-(def (__start argv)
+(def (__start argv interactive)
   (__init_globals)
+  (set! *argv* argv)
+  (set! *interactive* interactive)
   (if (cons? (cdr argv))
       (begin (set! *argv* (cdr argv))
-             (set! *interactive* nil)
              (__script (cadr argv)))
-      (begin (set! *argv* argv)
-             (set! *interactive* t)
-             (__rcscript)
-             (repl)))
+      (set! *interactive* t))
+  (when *interactive*
+    (__rcscript)
+    (repl))
   (exit 0))
 
 (def (add-exit-hook fun)