[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: executing bash function with shell-command
From: |
Emanuel Berg |
Subject: |
Re: executing bash function with shell-command |
Date: |
Tue, 23 Feb 2016 01:27:05 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
mvar <mvar.40k@gmail.com> writes:
> I've been trying to setup a lisp function in emacs
> (24.5.1) that executes an external bash function
> defined in my .bashrc file (or even .emacs_bash).
> If i open the shell directly from within emacs and
> type the function in there it works, but if i call
> it with "shell-command" i get a "command not
> found" error.
It is because when you open bash from Emacs bash is
the interactive shell. When you open Emacs from bash
Emacs talks to a non-interactive bash where BASH_ENV
is the only thing that is sourced. (Or so I've heard -
I don't use bash myself - I use zsh, where you solve
this by putting shared stuff in .zshenv)
So try putting the shared file path in BASH_ENV, or
you can even try:
BASH_ENV=~/.bashrc emacs
The the distinction interactive/non-interactive gets
foggy but I suppose your computer won't blow up.
> A workaround is to run shell-command with "source
> ~/.emacs-bash && function_name".
Indeed, the material is not read is the problem.
> another question, is it viable to create some
> function/script in Lisp that for example will ssh to
> a remote machine, execute some pre-defined commands
> and log-off ? The only relevant info i've found so
> far is for remote editing with tramp.
Yes, you can do that.
--
underground experts united
http://user.it.uu.se/~embe8573