Skip to content

Commit

Permalink
make sure server scripts start with shebang
Browse files Browse the repository at this point in the history
  • Loading branch information
wh1te909 committed Jul 8, 2024
1 parent ce4c3a7 commit 52ee688
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/components/scripts/ScriptFormModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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: {
Expand Down

0 comments on commit 52ee688

Please sign in to comment.