Subject: Re: bug#48579: 28.0.50; Spawning an emacs process using call-process results in inconsistent, behavior between GNU/Linux and macOS

From: Alan Third <[email-masked]>
Date: Sat, 22 May 2021 14:01:06 +0100

On Sat, May 22, 2021 at 02:14:53PM +0200, Daniel Mendler wrote:
> On 5/22/21 2:06 PM, Alan Third wrote:
> > On Sat, May 22, 2021 at 01:44:27PM +0200, Daniel Mendler wrote:
> >> Both GNU/Linux and macOS are Unixes, it is expected that Emacs behaves
> >> in the same way on both platforms with regards to handling the current
> >> directory. When Emacs is started via the command line or via forking
> >> from another process, Emacs should inherit the default directory from
> >> the parent process. If Emacs is started via some special finder or
> >> desktop application, the default directory of that finder application is
> >> taken. This is all predictable and expected.
> > 
> > If you want Emacs on macOS to work like a Unix command line app, then
> > build it as a Unix command line app, not a macOS GUI app.
> 
> I am not talking about GUI vs terminal,

You kind of are. The only reason this would happen is that the emacs
executable you're executing is within the GUI app bundle or at least
has been built to run as such.

> the problem here is if Emacs is started from a script. Would it be
> possible to adjust the directory changing behavior, for example if
> Emacs is started with the arguments `--daemon`, `--batch` or
> `--script`? Is there another way to detect if the finder launched
> Emacs, such that only in that case the directory changing to the
> home directory takes place?

You can run with "-t", "-nw", "--chdir", "--batch" or "--script" to
disable this behaviour.

-- 
Alan Third