From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Matthew Flaschen Newsgroups: gmane.emacs.help Subject: Re: "source" shell commands Date: Sat, 24 Mar 2007 17:21:07 -0400 Message-ID: <46059643.8090705@gatech.edu> References: <87bqii936r.fsf@baldur.tsdh.de> <85wt16btg5.fsf@lola.goethe.zz> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1174771288 16999 80.91.229.12 (24 Mar 2007 21:21:28 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 24 Mar 2007 21:21:28 +0000 (UTC) To: emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Mar 24 22:21:25 2007 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.50) id 1HVDfx-0000MF-Fe for geh-help-gnu-emacs@m.gmane.org; Sat, 24 Mar 2007 22:21:25 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HVDi0-0005tj-N7 for geh-help-gnu-emacs@m.gmane.org; Sat, 24 Mar 2007 16:23:32 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HVDho-0005tV-M2 for help-gnu-emacs@gnu.org; Sat, 24 Mar 2007 17:23:20 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HVDhn-0005tH-4I for help-gnu-emacs@gnu.org; Sat, 24 Mar 2007 17:23:20 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HVDhn-0005tE-0t for help-gnu-emacs@gnu.org; Sat, 24 Mar 2007 16:23:19 -0500 Original-Received: from deliverator7.gatech.edu ([130.207.165.169]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA1:24) (Exim 4.60) (envelope-from ) id 1HVDfi-0000uD-UO for help-gnu-emacs@gnu.org; Sat, 24 Mar 2007 17:21:11 -0400 Original-Received: from deliverator7.gatech.edu (localhost [127.0.0.1]) by localhost (Postfix) with SMTP id 418D517C5 for ; Sat, 24 Mar 2007 17:21:10 -0400 (EDT) (envelope-from matthew.flaschen@gatech.edu) Original-Received: from mailprx2.gatech.edu (mailprx2.prism.gatech.edu [130.207.171.21]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (Client CN "smtp.mail.gatech.edu", Issuer "RSA Data Security, Inc." (verified OK)) by deliverator7.gatech.edu (Postfix) with ESMTP id 2F1D217AA for ; Sat, 24 Mar 2007 17:21:10 -0400 (EDT) (envelope-from matthew.flaschen@gatech.edu) Original-Received: from [128.61.73.81] (r73h81.res.gatech.edu [128.61.73.81]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) (sasl: method=PLAIN, username=mflaschen3@mailprx2.gatech.edu, sender=n/a) by mailprx2.gatech.edu (Postfix) with ESMTP id E4B3B2365 for ; Sat, 24 Mar 2007 17:21:08 -0400 (EDT) (envelope-from matthew.flaschen@gatech.edu) User-Agent: Thunderbird 1.5.0.10 (X11/20070306) In-Reply-To: X-Enigmail-Version: 0.94.3.0 X-detected-kernel: Solaris 9 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:42165 Archived-At: Barry Margolin wrote: > In article <85wt16btg5.fsf@lola.goethe.zz>, David Kastrup > wrote: > >> Tassilo Horn writes: >> >>> Matthew Flaschen 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). Matt Flaschen