From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ernest Newsgroups: gmane.emacs.help Subject: Re: shell-command fails to execute shell function Date: Tue, 11 Jan 2011 07:47:38 -0800 (PST) Organization: http://groups.google.com Message-ID: <3fb13a41-0117-4b2f-8a10-98af423d19c4@s9g2000vby.googlegroups.com> References: <50126229-51c9-4bec-911d-1bb4095ef8ed@35g2000prb.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: dough.gmane.org 1294764079 19242 80.91.229.12 (11 Jan 2011 16:41:19 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 11 Jan 2011 16:41:19 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jan 11 17:41:15 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PchHW-0004us-3b for geh-help-gnu-emacs@m.gmane.org; Tue, 11 Jan 2011 17:41:14 +0100 Original-Received: from localhost ([127.0.0.1]:41097 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PchHV-0000Xy-H8 for geh-help-gnu-emacs@m.gmane.org; Tue, 11 Jan 2011 11:41:13 -0500 Original-Path: usenet.stanford.edu!postnews.google.com!s9g2000vby.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 30 Original-NNTP-Posting-Host: 80.58.205.53 Original-X-Trace: posting.google.com 1294760858 3626 127.0.0.1 (11 Jan 2011 15:47:38 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Tue, 11 Jan 2011 15:47:38 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: s9g2000vby.googlegroups.com; posting-host=80.58.205.53; posting-account=dqre7QoAAABu2BxfYJNu4mwxpl46bWpP User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; ca; rv:1.9.1.15) Gecko/20101028 Iceweasel/3.0.1 (like Firefox/3.5.15),gzip(gfe) Original-Xref: usenet.stanford.edu gnu.emacs.help:184211 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:78389 Archived-At: On 10 Gen, 22:59, "Steven W. Orr" wrote: > On 1/10/2011 9:40 AM, ernest wrote: > > > Hi, > > I have a shell function defined in ~/.bashrc. > > When I try to run the function with shell-command, it fails with: > > /bin/bash: fm: command not found > > "fm" being the function's name. > > I suppose I could precede every command with "source ~/.bashr" > > but I'm sure there must be something more appropriate. > > Any comment welcome. > > Ernest > > When you log in you run the .bash_profile. If you have a .bashrc then it's the > responsibility of the .bash_profile to run the .bashrc. If you run a > non-interactive script which depends on a function which is defined in the > .bashrc then you will not by default get those functions. If you *really* > think this is what you want, you need to look at the BASH_ENV variable. > > Do not set any env vars in your .bashrc unless you need them for remote > commands. In that case, your .bashrc should check to see if it is running > non-interactive and set those very few env vars that you really think you > need. But, always set them in the .bash_profile. I thought .bashrc was read when the shell was non-interactive too. Looks like I was wrong. So, non-interactive shells do not read any init file, unless you explicitly set the BASH_ENV variable . . . Ok, thanks! -- Ernest