changeset 1997:e88181fe095d default tip

fix os scheme
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 11 Jul 2025 00:57:26 -0600
parents d5c21ca9703e
children
files src/luan/modules/IoLuan.java
diffstat 1 files changed, 20 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
diff -r d5c21ca9703e -r e88181fe095d src/luan/modules/IoLuan.java
--- a/src/luan/modules/IoLuan.java	Fri Jul 04 11:39:41 2025 -0600
+++ b/src/luan/modules/IoLuan.java	Fri Jul 11 00:57:26 2025 -0600
@@ -35,9 +35,12 @@
 import luan.LuanFunction;
 import luan.LuanException;
 import luan.modules.url.LuanUrl;
+import goodjava.logging.Logger;
+import goodjava.logging.LoggerFactory;
 
 
 public final class IoLuan {
+	private static final Logger logger = LoggerFactory.getLogger(IoLuan.class);
 
 	public static String read_console_line(String prompt) throws IOException {
 		if( prompt==null )
@@ -547,12 +550,12 @@
 	}
 
 
-	public static class BaseOs extends LuanIO {
-		private final String[] cmd;
-		private final File dir;
-		private Process proc = null;
+	public static abstract class BaseOs extends LuanIO {
+		final String cmd;
+		final File dir;
+		Process proc = null;
 
-		private BaseOs(Luan luan,String[] cmd,LuanTable options) throws IOException, LuanException {
+		private BaseOs(Luan luan,String cmd,LuanTable options) throws IOException, LuanException {
 			this.cmd = cmd;
 			File dir = null;
 			if( options != null ) {
@@ -567,9 +570,7 @@
 			this.dir = dir;
 		}
 
-		private void setProc() throws IOException {
-			proc = Runtime.getRuntime().exec(cmd,null,dir);
-		}
+		abstract void setProc() throws IOException;
 
 		private Process proc() throws IOException {
 			if( proc == null ) {
@@ -627,16 +628,25 @@
 
 	public static final class LuanOs extends BaseOs {
 		public LuanOs(Luan luan,String cmd,LuanTable options) throws IOException, LuanException {
-			super(luan,new String[]{cmd},options);
+			super(luan,cmd,options);
 			check(luan,"os:"+cmd);
 		}
+
+		@Override void setProc() throws IOException {
+			proc = Runtime.getRuntime().exec(cmd,null,dir);
+		}
 	}
 
 	public static final class LuanBash extends BaseOs {
 		public LuanBash(Luan luan,String cmd,LuanTable options) throws IOException, LuanException {
-			super(luan,new String[]{"bash","-c",cmd},options);
+			super(luan,cmd,options);
 			check(luan,"bash:"+cmd);
 		}
+
+		@Override void setProc() throws IOException {
+			String[] a = new String[]{"bash","-c",cmd};
+			proc = Runtime.getRuntime().exec(a,null,dir);
+		}
 	}