From owner-freebsd-questions@FreeBSD.ORG Wed Dec 18 18:31:47 2013 Return-Path: Delivered-To: freebsd-questions@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 ESMTPS id EF0E8B3F for ; Wed, 18 Dec 2013 18:31:47 +0000 (UTC) Received: from mail.physics.umn.edu (smtp.spa.umn.edu [128.101.220.4]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id BFEEC1746 for ; Wed, 18 Dec 2013 18:31:47 +0000 (UTC) Received: from spa-sysadm-01.spa.umn.edu ([134.84.199.8]) by mail.physics.umn.edu with esmtpsa (TLSv1:CAMELLIA256-SHA:256) (Exim 4.77 (FreeBSD)) (envelope-from ) id 1VtLDO-000P5P-KS for freebsd-questions@freebsd.org; Wed, 18 Dec 2013 11:47:24 -0600 Message-ID: <52B1DFAB.8030300@physics.umn.edu> Date: Wed, 18 Dec 2013 11:47:23 -0600 From: Graham Allan User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20131028 Thunderbird/17.0.10 MIME-Version: 1.0 To: freebsd-questions@freebsd.org References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on mrmachenry.spa.umn.edu X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, TW_HR,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 Subject: Re: System Wide Bash Login Script X-SA-Exim-Version: 4.2 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Dec 2013 18:31:48 -0000 On 12/18/2013 11:26 AM, Drew Tomlinson wrote: > On 12/17/2013 3:56 PM, Matthew Pherigo wrote: >> Hi Drew! >> >> Believe it or not, systemwide bashrc sourcing isn't actually built-in >> to bash by default (though in my opinion, it should be). This behavior >> of global config sourcing actually comes from default /etc/profile >> files that come with Linux distros. Since FreeBSD uses csh/tcsh by >> default, of course, it comes with no such thing. However, it's fairly >> easy to add. The following snippet of code goes into your /etc/profile: >> >> if [ "$PS1" ]; then >> if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then >> if [ -f /usr/local/etc/bash.bashrc ]; then >> fi >> fi >> fi >> >> If the shell is interactive, is a bash shell, and the file >> /usr/local/etc/bash.bashrc exists, it sources it. >> >> This is the snippet of code I use; I think it was originally from Debian. >> --Matt > > Hi Matt, > > Thanks for your reply. The snippet of code you provided does work. > However, I remain confused. > > I have a box I built a couple of years ago which is currently at 9.1. I > don't recall how I got bash login scripts working on that one but it > appears that I put my commands in /usr/local/etc/bashrc. The > /etc/profile on that box is the default where everything is commented > out. So no code is needed on that box to get the commands in > /usr/local/etc/bashrc to run when logging in. > > I'm just trying to understand why the /etc/profile trick is required on > this new box I built but not the old? There's a compile-time option in config-top.h ("#define SYS_BASHRC ..."), which nobody seems to use. Back when we used to build our own bash from tarballs for long-gone proprietary unix systems, I always used to set these options. It was a huge PITA that the prebuilt packages on linux don't have this set and for a while we built our own custom version with the feature re-enabled but eventually it began to feel too much like swimming upstream. I guess we gave up this issue on FreeBSD as well! I still don't understand why bash people don't see the value in this feature - having to insert that snippet into everybody's personal bashrc is just stupid IMO... Graham -- ------------------------------------------------------------------------- Graham Allan - allan@physics.umn.edu - (612) 624-5040 School of Physics and Astronomy - University of Minnesota -------------------------------------------------------------------------