Browse Source

Added shebang example to Command line tutorial (#4028)

Co-authored-by: Hugo Locurcio <[email protected]>
Wilson E. Alvarez 4 years ago
parent
commit
1c4eab3f50
1 changed files with 19 additions and 2 deletions
  1. 19 2
      getting_started/editor/command_line_tutorial.rst

+ 19 - 2
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