Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15432

Re: [PATCH] docs: More hints on #! parsing

From Stephane Chazelas <stephane.chazelas@gmail.com>
Newsgroups gnu.bash.bug
Subject Re: [PATCH] docs: More hints on #! parsing
Date 2019-09-25 22:36 +0100
Message-ID <mailman.1109.1569447471.2190.bug-bash@gnu.org> (permalink)
References <20190925203324.16276-1-eblake@redhat.com> <20190925213641.2al2rhiuh2plrffh@chaz.gmail.com>

Show all headers | View raw


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

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: [PATCH] docs: More hints on #! parsing Stephane Chazelas <stephane.chazelas@gmail.com> - 2019-09-25 22:36 +0100

csiph-web