From 52ee688259b36607c309cc193e4bdd0c8bce904c Mon Sep 17 00:00:00 2001 From: wh1te909 <7434746+wh1te909@users.noreply.github.com> Date: Mon, 8 Jul 2024 19:01:21 +0000 Subject: [PATCH] make sure server scripts start with shebang --- src/components/scripts/ScriptFormModal.vue | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/scripts/ScriptFormModal.vue b/src/components/scripts/ScriptFormModal.vue index 88ccd4a4..b0cb5bf9 100644 --- a/src/components/scripts/ScriptFormModal.vue +++ b/src/components/scripts/ScriptFormModal.vue @@ -231,7 +231,7 @@ import { useQuasar, useDialogPluginComponent } from "quasar"; import { saveScript, editScript, downloadScript } from "@/api/scripts"; import { useAgentDropdown, agentPlatformOptions } from "@/composables/agents"; import { generateScript } from "@/api/core"; -import { notifySuccess } from "@/utils/notify"; +import { notifyError, notifySuccess } from "@/utils/notify"; // ui imports import TestScriptModal from "@/components/scripts/TestScriptModal.vue"; @@ -325,7 +325,7 @@ const agentLoading = ref(false); const missingShebang = computed(() => { if (script.shell === "shell" || script.shell === "python") { - return !script.script_body.includes("#!"); + return !script.script_body.startsWith("#!"); } else { return false; } @@ -385,6 +385,13 @@ async function submit() { } function openTestScriptModal(ctx: string) { + if (ctx === "server" && !script.script_body.startsWith("#!")) { + notifyError( + "A shebang is required at the top of the script to specify the interpreter's path. Please ensure your script begins with a shebang line.", + 7000, + ); + return; + } $q.dialog({ component: TestScriptModal, componentProps: {