all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jim Porter <jporterbugs@gmail.com>
To: Colton Lewis <coltonlewis@google.com>, 57370@debbugs.gnu.org
Subject: bug#57370: 28.1; eshell/addpath does not work when called noninteractively
Date: Tue, 23 Aug 2022 17:16:33 -0700	[thread overview]
Message-ID: <3554adec-a5b3-b345-ff75-cf798654c0db@gmail.com> (raw)
In-Reply-To: <gsnttu627l42.fsf@coltonlewis-kvm.c.googlers.com>

On 8/23/2022 1:36 PM, Colton Lewis via Bug reports for GNU Emacs, the 
Swiss army knife of text editors wrote:
> Discovered this trying to add a path from my init file and I just could
> not make it work.
> 
> 1. Create an executable script ~/test-bin/test.sh
> 2. emacs -Q
> 3. Eval the elisp snippet `(require 'eshell) (eshell/addpath "~/test-bin")`
> 4. Start eshell
> 5. test.sh
> 6. Observe command not found error
> 
> Substituting `(eshell/addpath (file-truename "~/test-bin"))` gives the same
> problem.
> 
> This should have the same effect as starting eshell immediately and
> executing `addpath ~/test-bin`, which has the expected result.

I can't speak to the other issues you mentioned in this bug, but I 
wouldn't expect calls to any 'eshell/FOO' function to work outside of an 
Eshell prompt. Many of them assume the presence of various 
local/internal Eshell variables, so they wouldn't work if you called 
them from a different context.

To run some Eshell command, you could use 'eshell-command' or 
'eshell-command-result', as in:

   (eshell-command-result "echo hi there")
     => ("hi" "there")

However, that's not useful for calling 'eshell/addpath', since Eshell 
buffers have their own local 'process-environment'. You'd just be 
updating PATH in a temporary Eshell buffer, and then it'd go away 
immediately when the buffer is closed.

> The only workaround I've found is to modify PATH directly with setenv
> and getenv.

I think that's the best method. You could probably do it via 
'eshell-mode-hook' if you wanted to change the PATH only for Eshell.





  parent reply	other threads:[~2022-08-24  0:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-23 20:36 bug#57370: 28.1; eshell/addpath does not work when called noninteractively Colton Lewis via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-08-23 22:49 ` bug#57370: Problem is more general than reported Colton Lewis via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-08-23 22:53 ` bug#57370: One More Thing Colton Lewis via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-08-24  0:16 ` Jim Porter [this message]
2022-09-03 12:26 ` bug#57370: 28.1; eshell/addpath does not work when called noninteractively Lars Ingebrigtsen

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=3554adec-a5b3-b345-ff75-cf798654c0db@gmail.com \
    --to=jporterbugs@gmail.com \
    --cc=57370@debbugs.gnu.org \
    --cc=coltonlewis@google.com \
    /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.