From owner-freebsd-hackers@FreeBSD.ORG Sun Sep 22 23:45:59 2013 Return-Path: Delivered-To: freebsd-hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 5F9A485B; Sun, 22 Sep 2013 23:45:59 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from mail0.glenbarber.us (mail0.glenbarber.us [IPv6:2607:fc50:1:2300:1001:1001:1001:face]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 3229F2FF2; Sun, 22 Sep 2013 23:45:59 +0000 (UTC) Received: from glenbarber.us (c-71-224-221-174.hsd1.nj.comcast.net [71.224.221.174]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: gjb) by mail0.glenbarber.us (Postfix) with ESMTPSA id 1F1A4407A; Sun, 22 Sep 2013 23:45:57 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.8.3 mail0.glenbarber.us 1F1A4407A Authentication-Results: mail0.glenbarber.us; dkim=none reason="no signature"; dkim-adsp=none Date: Sun, 22 Sep 2013 19:45:55 -0400 From: Glen Barber To: Ian Lepore Subject: Re: The right way to invoke sh from a freebsd makefile? Message-ID: <20130922234555.GE2336@glenbarber.us> References: <1379891905.1197.115.camel@revolution.hippie.lan> <20130922232710.GD2336@glenbarber.us> <1379893071.1197.119.camel@revolution.hippie.lan> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="5xSkJheCpeK0RUEJ" Content-Disposition: inline In-Reply-To: <1379893071.1197.119.camel@revolution.hippie.lan> X-Operating-System: FreeBSD 10.0-ALPHA2 amd64 User-Agent: Mutt/1.5.21 (2010-09-15) Cc: FreeBSD Hackers , freebsd-current X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Sep 2013 23:45:59 -0000 --5xSkJheCpeK0RUEJ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Sep 22, 2013 at 05:37:51PM -0600, Ian Lepore wrote: > On Sun, 2013-09-22 at 19:27 -0400, Glen Barber wrote: > > On Sun, Sep 22, 2013 at 05:18:25PM -0600, Ian Lepore wrote: > > > What's the right way to launch the bourne shell from a makefile? I h= ad > > > assumed the ${SHELL} variable would be set to "the right" copy > > > of /bin/sh (like maybe the one in tmp or legacy at various stages). = It > > > appears that that's not the case, and ${SHELL} is whatever comes from > > > the environment, which can lead to using csh or bash or whatever. > > >=20 > > > I see some of our makefiles use just a bare "sh" which seems reasonab= le > > > to me, but I don't want to glitch this in src/include/Makefile again. > > > The goal is to run a script in src/include/Makefile by launching sh w= ith > > > the script name (as opposed to launching the script and letting the #! > > > do its thing, which doesn't work if the source dir is mounted noexec). > > >=20 > >=20 > > I think BUILDENV_SHELL is what you are looking for. For this specific > > case, I think instead of '#!/bin/sh', maybe '#!/usr/bin/env sh' may be > > preferable. > >=20 > > Glen > >=20 >=20 > No, BUILDENV_SHELL is a special thing... it's used when you "make > buildenv" to chroot into a cross-build environment to work > interactively. I added that long ago because I can't live in a csh > shell (I mean, I can't do anything, I'm totally lost), and I wanted a > way to have "make buildenv" put me right into bash (of course, you have > to have bash in the chroot). >=20 Ah, right. Thanks for the sanity check. > The flavor of hashbang to use shouldn't matter, since what I'm after > here is launching the shell to run the script without using the hashbang > mechanism. >=20 You can hard-code /bin/sh directly, but what I was getting at with the '#!/usr/bin/env sh' is that the 'sh' interpreter of the build environment could be used (instead of /bin/sh directly). Then you don't need to worry about the path to sh(1). Glen --5xSkJheCpeK0RUEJ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.21 (FreeBSD) iQEcBAEBCAAGBQJSP4EzAAoJEFJPDDeguUajQWUIAKaWdeFQxJahvN2CEgAFGhB/ Ftoj1nas+yeDG3jRCEgAHF9jdiyAPZKF/UGFFtJTdH7NfQRpaO7fKjucKoTvAa5k atypjFpIYVRmyJGgI5KkwvMMYtjhUoYopkyZCi2SLZlFXhVTFInKZxsHu6lJwXkW yGAo9KRKeFGFnu3XcF02OWlpaE5yHocvzrgCM7D1mrLyRzwxxpLjyRqb4MrZ08uJ /JkMODxkpiRASPQERoYfL3M2B5RLoZsYvPG1vLI/ehl+CnhUTIQehXDQGrQCMkAA zkyrQUWggv2vyiV/6EQv3lIzrKgrJITMJnjUmrcVdvLffSU/gAn3huLKeZkwMbY= =rtRm -----END PGP SIGNATURE----- --5xSkJheCpeK0RUEJ--