all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* shell-command fails to execute shell function
@ 2011-01-10 14:40 ernest
  2011-01-10 21:59 ` Steven W. Orr
       [not found] ` <mailman.1.1294696768.5286.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 4+ messages in thread
From: ernest @ 2011-01-10 14:40 UTC (permalink / raw)
  To: help-gnu-emacs

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: shell-command fails to execute shell function
  2011-01-10 14:40 shell-command fails to execute shell function ernest
@ 2011-01-10 21:59 ` Steven W. Orr
  2011-01-10 22:11   ` Peter Dyballa
       [not found] ` <mailman.1.1294696768.5286.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 4+ messages in thread
From: Steven W. Orr @ 2011-01-10 21:59 UTC (permalink / raw)
  To: help-gnu-emacs

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.

-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: shell-command fails to execute shell function
  2011-01-10 21:59 ` Steven W. Orr
@ 2011-01-10 22:11   ` Peter Dyballa
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Dyballa @ 2011-01-10 22:11 UTC (permalink / raw)
  To: Steven W. Orr; +Cc: help-gnu-emacs


Am 10.01.2011 um 22:59 schrieb Steven W. Orr:

> But, always set them in the .bash_profile.


It would also work to put GNU Emacs related things into ~/.emacs_bash  
– for example as:

	.  ~/.bashrc

I set in ~/.emacs_bash PS1 and have:

	BASH_ENV=${HOME}/Library/init/bash/aliases.mine

--
Greetings

   Pete

A morning without coffee is like something without something else.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: shell-command fails to execute shell function
       [not found] ` <mailman.1.1294696768.5286.help-gnu-emacs@gnu.org>
@ 2011-01-11 15:47   ` ernest
  0 siblings, 0 replies; 4+ messages in thread
From: ernest @ 2011-01-11 15:47 UTC (permalink / raw)
  To: help-gnu-emacs

On 10 Gen, 22:59, "Steven W. Orr" <ste...@syslang.net> 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-01-11 15:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-10 14:40 shell-command fails to execute shell function ernest
2011-01-10 21:59 ` Steven W. Orr
2011-01-10 22:11   ` Peter Dyballa
     [not found] ` <mailman.1.1294696768.5286.help-gnu-emacs@gnu.org>
2011-01-11 15:47   ` ernest

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.