[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] docs: More hints on #! parsing
From: |
Stephane Chazelas |
Subject: |
Re: [PATCH] docs: More hints on #! parsing |
Date: |
Wed, 25 Sep 2019 22:36:41 +0100 |
User-agent: |
NeoMutt/20171215 |
2019-09-25 15:33:24 -0500, Eric Blake:
[...]
> Bash scripts often begin with @code{#! /bin/bash} (assuming that
> Bash has been installed in @file{/bin}), since this ensures that
> Bash will be used to interpret the script, even if it is executed
> -under another shell.
> +under another shell. Another common practice is the use of
> +@code{#!/bin/env bash} to find the first instance of bash on @env{PATH}.
[...]
env is more commonly found in /usr/bin. There's no env in /bin
on Ubuntu or FreeBSD for instance.
Using "#! /bin/bash -" is also good practice (so your script
still works when its path starts with - or +, see also
https://unix.stackexchange.com/questions/351729/why-the-in-the-bin-sh-shebang
for more historical context).
--
Stephane