Skip to content

[FEATURE] Support for goto and Labels in Scripts #240

@Shelushun

Description

@Shelushun

Is your feature request related to a problem? Please describe.
Currently, the scripting engine does not support goto statements and labels, which makes it difficult to:
Create flexible control flow (for example, repeating a block of code without duplication).
Handle errors with the transition to the cleanup section.
Emulate loops or complex conditions in limited scripting languages.

Without this, users have to:
Write redundant code with duplication.
Use crutches (for example, external loops or manual flag control).
Switch to less convenient languages just for the sake of controlling the flow of execution.

describe the solution you'd like
I propose adding:

Labels in the format :name.
The goto operator for navigating to a placemark, for example:


:retry
echo "Attempting operation..."
goto retry

(Optional) Support for conditional transitions (if error goto fail).
This would align with classic batch scripting and simple automation tools, making scripts more powerful without complex syntax.

Describe alternatives you've considered
Functions: But they may not be present in minimalistic scripting engines.
Cycles: Not always suitable for non-linear flow.
External preprocessors: Complicate development.
Goto is a simple and versatile solution for basic flow control.

Additional content
An example from real use:

:start
inject --payload=test
if error goto cleanup
echo "Success!"
exit


:cleanup
echo "Failed, retrying..."
goto start

There are analogues in Bash, Batch, and even Python (via goto from third-party libraries).

Thank you for your consideration!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions