From 99083a2c026018f30f9779fbcb3607efb09bec05 Mon Sep 17 00:00:00 2001 From: tiyn Date: Wed, 15 Jul 2026 14:11:44 +0200 Subject: [PATCH] Python: Added Shebang Usage --- wiki/linux/shell.md | 38 ++++++++++++++++++++++++++ wiki/programming_language/python.md | 17 ++++++++++++ wiki/programming_language/python/uv.md | 16 ++++++++++- 3 files changed, 70 insertions(+), 1 deletion(-) diff --git a/wiki/linux/shell.md b/wiki/linux/shell.md index e14364d..ee52b68 100644 --- a/wiki/linux/shell.md +++ b/wiki/linux/shell.md @@ -35,6 +35,44 @@ There are similar repositories and resources for functions that are outside the shells. Because of that and their issue regarding compatibility they will not be mentioned here. +### Shebangs + +A shebang specifies which interpreter should execute a script. +It is written as the first line of the file and starts with `#!`. + +For example, a [POSIX shell](#unix-shells) script typically begins with the following. + +```sh +#!/bin/sh +``` + +A [Bash](#unix-shells) script commonly uses the following line. + +```sh +#!/usr/bin/env bash +``` + +Using `/usr/bin/env` causes the interpreter to be resolved through the current `PATH` instead of +using a fixed path. +This makes scripts more portable and allows them to use interpreters provided by virtual +environments—for example +[Pythons virtual environments](/wiki/programming_language/python.md#using-virtual-environments)—or +other tools. + +To execute a script directly, it first has to be marked as executable. + +```sh +chmod +x