From 1c4eab3f50cf08b543ceb89ed66f5fcd595fdbda Mon Sep 17 00:00:00 2001 From: "Wilson E. Alvarez" Date: Thu, 17 Sep 2020 17:53:54 -0400 Subject: [PATCH] Added shebang example to Command line tutorial (#4028) Co-authored-by: Hugo Locurcio --- .../editor/command_line_tutorial.rst | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/getting_started/editor/command_line_tutorial.rst b/getting_started/editor/command_line_tutorial.rst index cabc85fd5..c55eef9e4 100644 --- a/getting_started/editor/command_line_tutorial.rst +++ b/getting_started/editor/command_line_tutorial.rst @@ -306,11 +306,11 @@ conversion of assets or custom import/export. The script must inherit from ``SceneTree`` or ``MainLoop``. -Here is a simple example of how it works: +Here is a simple ``sayhello.gd`` example of how it works: .. code-block:: python - # sayhello.gd + #!/usr/bin/env -S godot -s extends SceneTree func _init(): @@ -326,3 +326,20 @@ And how to run it: If no ``project.godot`` exists at the path, current path is assumed to be the current working directory (unless ``--path`` is specified). + +The first line of ``sayhello.gd`` above is commonly referred to as +a *shebang*. If the Godot binary is in your ``PATH`` as ``godot``, +it allows you to run the script as follows in modern Linux +distributions, as well as macOS: + +:: + # Mark script as executable. + chmod +x sayhello.gd + # Prints "Hello!" to standard output. + ./sayhello.gd + +If the above doesn't work in your current version of Linux or macOS, you can +always have the shebang run Godot straight from where it is located as follows: + +:: + #!/usr/bin/godot -s