From owner-freebsd-questions@FreeBSD.ORG Tue Apr 13 20:01:34 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 587BB16A4CE for ; Tue, 13 Apr 2004 20:01:34 -0700 (PDT) Received: from priv-edtnes56.telusplanet.net (outbound01.telus.net [199.185.220.220]) by mx1.FreeBSD.org (Postfix) with ESMTP id D5EC143D60 for ; Tue, 13 Apr 2004 20:01:31 -0700 (PDT) (envelope-from viktorlazlo@telus.net) Received: from byx0rm.mr-clevver.com ([206.116.67.130]) by priv-edtnes56.telusplanet.netESMTP <20040414030131.NFEO5572.priv-edtnes56.telusplanet.net@byx0rm.mr-clevver.com>; Tue, 13 Apr 2004 21:01:31 -0600 Date: Tue, 13 Apr 2004 20:02:58 -0700 (PDT) From: Viktor Lazlo X-X-Sender: viktorlazlo@byx0rm.mr-clevver.com To: fudo In-Reply-To: Message-ID: <20040413185748.T95123@byx0rm.mr-clevver.com> References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-questions@freebsd.org Subject: Re: problems with .bashrc X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Apr 2004 03:01:34 -0000 On Tue, 13 Apr 2004, fudo wrote: > I'm new to FreeBSD, and to bash. I'm running FreeBSD 5.0, and added > bash from the cd during install. There are .profile and .shrc files in > my home directory; .profile references .shrc with ENV=$HOME/.shrc; > export ENV. There are several uncommented alias lines in the .shrc > file, but none of them work. From what I've read, bash should read > .profile and .shrc, but just in case, I tried copying them to > .bash_profile and .bashrc, changing ENV to =$HOME/.bashrc, and renaming > the original files, but the aliases still don't work. Aliases are > formatted: alias ll='ls -laFo'; entering that at the prompt and it > works fine. Seems like bash isn't reading the rc file. Obviously, I'm > missing something; any suggestions appreciated. Thanks. I think what is happening is the aliases in .shrc are not read directly by bash unless invoked as sh, and the .shrc assigned to ENV is only read for non-login shells; I'm not sure why they wouldn't work when entered in .bash_profile, but the fact that they don't suggests a conflict between the files the commands are entered in and the order in which they are read. When invoked as bash (not sh) the start-up files that bash reads for a login shell are, in order: i) /etc/profile and then the first of any of the following that exists: ii) ~/.bash_profile OR iii) ~/.bash_login OR iv) ~/.profile Non-login interactive bash shells (when changing or starting new shells during a session) read only ~/.bashrc. Non-login non-interactive bash shells (ie-when launched from inside a script) check the startup file in $BASH_ENV, or $ENV if that doesn't exist. An easy way to make sure all three invocations of bash reference the same start-up file is: i) use .bashrc as your customized startup file ii) create a .bash_profile containing only: export BASH_ENV=~/.bashrc if [ -f ~/.bashrc ]; then source ~/.bashrc; fi This way, after reading /etc/profile a login shell will read the first file found, ~/.bash_profile, which in turn reads ~/.bashrc Non-login interactive shells will read ~/.bashrc as usual Non-login non-interactive shells will read the ~/.bashrc assigned in $BASH_ENV. Cheers, Viktor