all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Matthew Flaschen <matthew.flaschen@gatech.edu>
To: emacs <help-gnu-emacs@gnu.org>
Subject: Re: "source" shell commands
Date: Sun, 25 Mar 2007 00:03:10 -0400	[thread overview]
Message-ID: <4605F47E.1080708@gatech.edu> (raw)
In-Reply-To: <87hcsaqbui.fsf@lion.rapttech.com.au>

Tim X wrote:
> Matthew Flaschen <matthew.flaschen@gatech.edu> writes:
> 
>> Barry Margolin wrote:
>>> In article <85wt16btg5.fsf@lola.goethe.zz>, David Kastrup <dak@gnu.org> 
>>> wrote:
>>>
>>>> Tassilo Horn <tassilo@member.fsf.org> writes:
>>>>
>>>>> Matthew Flaschen <matthew.flaschen@gatech.edu> writes:
>>>>>
>>>>>> Is there an elisp function to "source" a shell file; i.e. an
>>>>>> alternative to:
>>>>>>
>>>>>> (shell-command (concat "source \"" (expand-file-name "~/.rc") "\""))
>>>>> Sure.
>>>>>
>>>>> --8<---------------cut here---------------start------------->8---
>>>>> (defun mf-source (file)
>>>>>   (interactive "f")
>>>>>   (shell-command (concat "source \"" file "\"")))
>>>>> --8<---------------cut here---------------end--------------->8---
>>>> Quoting is always good for trouble.  I'd rather use
>>>>
>>>> (defun mf-source (file)
>>>>   (interactive "f")
>>>>   (call-process shell-file-name nil nil nil "source" file))
>>>>
>>>> assuming that you don't care about the output.
>>> First of all, shells don't take a command line to execute as arguments.  
>>> Take a look at what happens if you try it from the command line:
>>>
>>> $ bash source .bashrc
>>> source: source: No such file or directory
>>>
>>> You can do it with the -c option, but then they expect the command to be 
>>> in a single argument:
>>>
>>> (call-process shell-file-name nil nil nil 
>>>               "-c" (format "source '%s'" file))
>>>
>>> Second, the point of "sourcing" is to execute the commands in the 
>>> current process's context.  Since call-process and shell-command both 
>>> execute a child process, nothing that occurs in the sourced script will 
>>> have any effect on the emacs process.  So even if you get the syntax 
>>> right, it won't do anything different from executing the script normally.
>> Thanks.  I realized this after I asked the question.  Is there any way I
>> could import the variables after?  I found
>> shell-copy-environment-variable but I reall want to copy *all* of them
>> (for when I start emacs from outside the shell).
>>
> 
> I doubt shell-copy-environment-variable will work either. As soon as the sub
> process that executes the "source file" has exited, I think that envrionment is
> gone. 
> 
> I'm curious, how are you starting emacs "from outside the shell"?

Maybe I'm missing something big.  I'm using KDE.  Sometimes I start
emacs from an xterm (Konsole actually), but sometimes I just click a
shortcut.

> The first and easiest is to change the shell that executes your
> .Xsession (or equivalent) to a login shell.

Any idea how I would do that in Ubuntu (gNewSense really)?

Matthew Flaschen

  reply	other threads:[~2007-03-25  4:03 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.1360.1174733204.7795.help-gnu-emacs@gnu.org>
2007-03-24 13:33 ` "source" shell commands Tassilo Horn
2007-03-24 14:35   ` David Kastrup
2007-03-24 15:24     ` Barry Margolin
2007-03-24 21:21       ` Matthew Flaschen
2007-03-25  0:08         ` Matthew Flaschen
2007-03-25 10:33           ` Peter Dyballa
2007-03-25 10:55             ` Matthew Flaschen
2007-03-25 11:53               ` Peter Dyballa
2007-03-26  0:44                 ` Matthew Flaschen
2007-03-26  8:16                   ` Peter Dyballa
2007-03-26  9:59                     ` Matthew Flaschen
     [not found]               ` <mailman.1412.1174823876.7795.help-gnu-emacs@gnu.org>
2007-03-25 22:36                 ` Tim X
2007-03-26  0:53                   ` Matthew Flaschen
     [not found]                   ` <mailman.1432.1174870550.7795.help-gnu-emacs@gnu.org>
2007-03-26 11:30                     ` Tim X
     [not found]       ` <mailman.1381.1174771402.7795.help-gnu-emacs@gnu.org>
2007-03-25  2:46         ` Tim X
2007-03-25  4:03           ` Matthew Flaschen [this message]
     [not found]           ` <mailman.1397.1174795525.7795.help-gnu-emacs@gnu.org>
2007-03-25 10:56             ` Tim X
2007-03-26  8:13             ` Tassilo Horn
2007-03-26  8:57               ` Matthew Flaschen
     [not found]               ` <mailman.1436.1174899596.7795.help-gnu-emacs@gnu.org>
2007-03-26  9:08                 ` Tassilo Horn
2007-03-26  9:55                   ` Matthew Flaschen
2007-03-25  2:32 ` Tim X
2007-03-25  2:59   ` Matthew Flaschen
2007-03-24 10:44 Matthew Flaschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4605F47E.1080708@gatech.edu \
    --to=matthew.flaschen@gatech.edu \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.