mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-03 05:48:42 +03:00
Added shebang example to Command line tutorial (#4028)
Co-authored-by: Hugo Locurcio <hugo.locurcio@hugo.pro>
This commit is contained in:
committed by
GitHub
parent
13b80b9faf
commit
1c4eab3f50
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user