From e650911d8007cf842d69ebffce197ae220f13a5f Mon Sep 17 00:00:00 2001 From: dginovker Date: Mon, 25 Sep 2023 01:15:25 +0900 Subject: [PATCH] Convert some code to work on more than only Linux and Windows (BSD, MacOS), fix script compile script not compiling due to French characters in code --- build.xml | 4 ++-- client/src/main/java/com/aposbot/gui/ScriptFrame.java | 11 +++++++---- compile_all_linux.sh | 2 +- compile_scripts-linux.sh | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) mode change 100644 => 100755 compile_scripts-linux.sh diff --git a/build.xml b/build.xml index 451fa04..e539279 100644 --- a/build.xml +++ b/build.xml @@ -27,7 +27,7 @@ - @@ -48,7 +48,7 @@ - diff --git a/client/src/main/java/com/aposbot/gui/ScriptFrame.java b/client/src/main/java/com/aposbot/gui/ScriptFrame.java index a5309ac..faecc7b 100644 --- a/client/src/main/java/com/aposbot/gui/ScriptFrame.java +++ b/client/src/main/java/com/aposbot/gui/ScriptFrame.java @@ -171,10 +171,13 @@ public final class ScriptFrame extends Frame { compileScriptsButton.addActionListener(e -> { try { final ProcessBuilder pb = new ProcessBuilder("cmd", "/c", "compile_scripts.cmd"); - // If we're on Linux, use bash instead of cmd - if (System.getProperty("os.name").toLowerCase().contains("linux")) { - pb.command("bash", "-c", "chmod +x compile_scripts-linux.sh && ./compile_scripts-linux.sh"); - } + // If we're on anything with sh, use the shell script instead + String os = System.getProperty("os.name").toLowerCase(); + + // Check if the OS is Unix-like (Linux, Mac, BSD, etc.) + if (os.contains("linux") || os.contains("mac") || os.contains("unix") || os.contains("bsd")) { + pb.command("sh", "-c", "chmod +x compile_scripts-linux.sh && ./compile_scripts-linux.sh"); + } // execute final Process p = pb.start(); // get both the output and the error stream diff --git a/compile_all_linux.sh b/compile_all_linux.sh index b6d2f43..0c3fa3a 100755 --- a/compile_all_linux.sh +++ b/compile_all_linux.sh @@ -1,3 +1,3 @@ -#!/bin/bash +#!/bin/sh ./apache-ant-1.10.12/bin/ant -f build.xml compile-all \ No newline at end of file diff --git a/compile_scripts-linux.sh b/compile_scripts-linux.sh old mode 100644 new mode 100755 index 7f32854..1875a80 --- a/compile_scripts-linux.sh +++ b/compile_scripts-linux.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # If there's not bot.jar in the folder, first call ./compile_all_linux.sh if [ ! -f bot.jar ]; then