From 949e33df7b68d565283ab2f622900e2533df1782 Mon Sep 17 00:00:00 2001 From: Coela Can't! <77935580+coelacant1@users.noreply.github.com> Date: Fri, 10 Jan 2025 11:58:00 -0500 Subject: [PATCH] Remove carriage return on scripts --- .check/ConvertLineEndings.py | 54 +++++++++++++++++++++++++++++++++++ .site/SingleLineCommand.png | Bin 33073 -> 33072 bytes CCPVEOffline.sh | 15 ++++++++-- 3 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 .check/ConvertLineEndings.py diff --git a/.check/ConvertLineEndings.py b/.check/ConvertLineEndings.py new file mode 100644 index 0000000..eee900f --- /dev/null +++ b/.check/ConvertLineEndings.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 + +import os +import sys + +def convert_line_endings_to_unix(directory): + """ + Walk through the given directory (recursively), converting + Windows-style line endings (\r\n) to Unix-style (\n), except + in any directory named '.github'. + """ + for root, dirs, files in os.walk(directory): + # Skip the .github directory (and its subfolders if any) + if ".github" in dirs: + dirs.remove(".github") + + for filename in files: + file_path = os.path.join(root, filename) + try: + # Read file in binary mode to see raw bytes + with open(file_path, "rb") as f: + content = f.read() + except OSError as e: + print(f"[ERROR] Could not open {file_path}: {e}") + continue + + # Replace CRLF with LF + new_content = content.replace(b"\r\n", b"\n") + + # Only write if there's a difference + if new_content != content: + try: + with open(file_path, "wb") as f: + f.write(new_content) + print(f"[INFO] Converted line endings in {file_path}") + except OSError as e: + print(f"[ERROR] Could not write to {file_path}: {e}") + + +def main(): + if len(sys.argv) != 2: + print("Usage: python convert_line_endings.py ") + sys.exit(1) + + directory = sys.argv[1] + + if not os.path.isdir(directory): + print(f"Error: {directory} is not a valid directory.") + sys.exit(1) + + convert_line_endings_to_unix(directory) + +if __name__ == "__main__": + main() diff --git a/.site/SingleLineCommand.png b/.site/SingleLineCommand.png index bec5479d0809d7f1d29edca8c9a4b8fc2404d7ff..c17fc6451420264a5820f5edcc0bb90c92a238cc 100644 GIT binary patch delta 15 Wcmdnk#I&J_iKR2Z&wV4SP9p#<4Fx{{ delta 16 Xcmdnc#I&)AiM2Dp&z*N8i%uf|F)js6 diff --git a/CCPVEOffline.sh b/CCPVEOffline.sh index 4b646fb..52e9028 100644 --- a/CCPVEOffline.sh +++ b/CCPVEOffline.sh @@ -178,9 +178,20 @@ run_script() { # Capture script output in an array, to truncate if needed declare -a output_lines if [ -x "$script_path" ]; then - mapfile -t output_lines < <("$script_path" "${param_array[@]}") + mapfile -t output_lines < <( + bash -c " + source \"./Utilities/Utilities.sh\" + exec \"${script_path}\" \"${param_array[@]}\" + " + ) + else - mapfile -t output_lines < <(bash "$script_path" "${param_array[@]}") + mapfile -t output_lines < <( + bash -c " + source \"./Utilities/Utilities.sh\" + exec bash \"${script_path}\" \"${param_array[@]}\" + " + ) fi LAST_SCRIPT="$(display_path "$script_path")"