GNU bug report logs - #48579
28.0.50; Spawning an emacs process using call-process results in inconsistent behavior between GNU/Linux and macOS

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: minor; Reported by: Raj Krishnan <rajkrishnan1996@HIDDEN>; dated Sat, 22 May 2021 07:36:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 48579 <at> debbugs.gnu.org:


Received: (at 48579) by debbugs.gnu.org; 23 May 2021 10:30:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun May 23 06:30:46 2021
Received: from localhost ([127.0.0.1]:40651 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lklNd-0007O6-QV
	for submit <at> debbugs.gnu.org; Sun, 23 May 2021 06:30:46 -0400
Received: from mail-wr1-f46.google.com ([209.85.221.46]:40607)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <p.stephani2@HIDDEN>) id 1lklNb-0007GU-48
 for 48579 <at> debbugs.gnu.org; Sun, 23 May 2021 06:30:45 -0400
Received: by mail-wr1-f46.google.com with SMTP id z17so25415727wrq.7
 for <48579 <at> debbugs.gnu.org>; Sun, 23 May 2021 03:30:43 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:subject:from:in-reply-to:date:cc
 :content-transfer-encoding:message-id:references:to;
 bh=e73TumUDZBvOtqOs8VWUVtkYdRsicq5hkeRtz6z0DpM=;
 b=iAOUt7KBA60I5xPXtizY6RZM/4wZIttiEBplX0dkx0ytQF5c1uxxg6MitAF4ByFFk6
 YAE7Z2Qe0hiTwwVkxK5+s6BB3ADXcxiiM/mPi6AlNkfrWDs3l2NpvMUcpiU7DIY14zyf
 GFMKQV4IqwUkV9DT3kn+6L7zjvyUFzOCjYvI1Z0WZCRvdcSkvB729Mel6tjqfNVSKgDv
 Xc/aKE0cRkb1qWAQ2z0DA2lyTpRXnt2ZgVSXDJwQytMSmkk7mWDWxRFwN8rcX0Do9Nhr
 pcpErzihlN1B4JuHTitmLjjBQ27swDy3kgSSW9k+pc/uXQrw8d7E8xROSmntnjY6B59M
 uyTw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc
 :content-transfer-encoding:message-id:references:to;
 bh=e73TumUDZBvOtqOs8VWUVtkYdRsicq5hkeRtz6z0DpM=;
 b=SpwWNPiy1swQCyCry8wGaYKJwNQFMHjbDJXYRj+ADCRRVuoBTwp9H3qMqjrnxQoRkz
 on1ixO0/hYFWEoUnLA4osmc9peUB/tH8OGrSmoZb3no7Z/J4DF+eLF4vjOEle8o1/Yay
 0sBsBOS4whLMKjtSDBUKiGJvjNThx5rTizGMu6QnwnvPNKIFF/0EbqiAoPCMKp0btlFy
 NN4ZxyO1puLy8XkmHts1TGkfYmXV9eBDQCxus6G52a/29N3nzuJ+awSTXVl4MsS/CjsA
 vjnyRTYnlU6KWbA60Wemhu8DJBffMhNzfeCNJk+zW4+FlZ8x2d//bRTESEIGDpepP235
 BcUg==
X-Gm-Message-State: AOAM532YaAE4+sTbBIQl535Y3QsUPvEpU0+q/mFcc1EieSjy+iyMu+5V
 rgYHVU/GcqBa6Kx6VFSZr9Y=
X-Google-Smtp-Source: ABdhPJyHNmaYGguQLnP+f3XoLHlwwXepCq9a4H0tV28Ytr1+5LmG/EZdrgZoCsQNG5wdf/yZMOqtNQ==
X-Received: by 2002:a05:6000:12cc:: with SMTP id
 l12mr17129200wrx.91.1621765837214; 
 Sun, 23 May 2021 03:30:37 -0700 (PDT)
Received: from smtpclient.apple ([46.128.198.100])
 by smtp.gmail.com with ESMTPSA id f18sm3153537wmc.40.2021.05.23.03.30.36
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Sun, 23 May 2021 03:30:36 -0700 (PDT)
Content-Type: text/plain;
	charset=us-ascii
Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.80.0.2.43\))
Subject: Re: bug#48579: 28.0.50; Spawning an emacs process using call-process
 results in inconsistent, behavior between GNU/Linux and macOS
From: Philipp <p.stephani2@HIDDEN>
In-Reply-To: <83y2c6kj9q.fsf@HIDDEN>
Date: Sun, 23 May 2021 12:30:36 +0200
Content-Transfer-Encoding: quoted-printable
Message-Id: <CF785650-A4E7-42E5-870B-A1384CDAABEB@HIDDEN>
References: <2d81bff4-21fc-ce96-f1f1-f0bbf60b233e@HIDDEN>
 <837djrklhx.fsf@HIDDEN>
 <ed6f5225-f1b4-fbda-286c-17138e45d63f@HIDDEN>
 <831r9zkkaq.fsf@HIDDEN>
 <e3bd2559-55f4-b944-56dd-532229fee2de@HIDDEN>
 <83y2c6kj9q.fsf@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
X-Mailer: Apple Mail (2.3654.80.0.2.43)
X-Spam-Score: 0.2 (/)
X-Debbugs-Envelope-To: 48579
Cc: Daniel Mendler <mail@HIDDEN>, Alan Third <alan@HIDDEN>,
 48579 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.8 (/)



> Am 22.05.2021 um 15:09 schrieb Eli Zaretskii <eliz@HIDDEN>:
>=20
> If you want to make sure that the default-directory of *scratch* is
> the directory where Emacs was started, we could add such a feature (it
> doesn't exists now, and relying on what you see on GNU/Linux means you
> are relying on one particular implementation).  However, even if we do
> introduce such a feature, that still won't tell you anything about the
> cwd of the Emacs process.  If this latter aspect is what you really
> care about, you will have to explain the rationale, because I don't
> see how it could be important.
>=20

The actual working directory as seen by the kernel/process should indeed =
be irrelevant.  What matters is that when processing command-line =
arguments in batch mode, Emacs behaves like other Unix tools in that it =
resolves relative filenames as relative to the working directory that =
was current when the process was started.  In other words, when =
executing

   emacs -Q -batch -eval '(print default-directory)'

from a shell, Emacs must always print a representation of the shell's =
current working directory (ignoring corner cases such as "default =
directory has been removed during process startup").  Guaranteeing that =
(a) when processing command-line arguments the *scratch* buffer is =
current (unless changed by a previous command-line argument), and (b) =
its default directory will be set to a representation of the initial =
process working directory should ensure that.  I guess that's already =
the case for all operating systems, and we only need to document it.=




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#48579; Package emacs. Full text available.

Message received at 48579 <at> debbugs.gnu.org:


Received: (at 48579) by debbugs.gnu.org; 22 May 2021 13:21:05 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat May 22 09:21:05 2021
Received: from localhost ([127.0.0.1]:38552 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lkRYv-0000Yb-5H
	for submit <at> debbugs.gnu.org; Sat, 22 May 2021 09:21:05 -0400
Received: from server.qxqx.de ([178.63.65.180]:60177 helo=mail.qxqx.de)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1lkRYt-0000Xn-FH
 for 48579 <at> debbugs.gnu.org; Sat, 22 May 2021 09:21:03 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=qxqx.de;
 s=mail1392553390; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:
 MIME-Version:Date:Message-ID:References:To:From:Subject:Sender:Reply-To:Cc:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=Lpo6QoHBvSfso4ojzqrrX4sbocWg50aHBEYDlOxYl7M=; b=Wb9eToyfvZ+4jdNpCTdvzgfzf8
 ldqRXEYCKyMMBuGth9oY8as8TWgbQDXojo/ChMR5cWI+72zFjWWuxiL4rKe5NDsegupLyfHDBt/Tp
 CPkXiMl5+AuuUQIxHreCuMgXZcb2y8rPsv2U6ovefip6Ik/ZG9Kz6ZlARCuTai4xa6RE=;
Subject: Re: bug#48579: 28.0.50; Spawning an emacs process using call-process
 results in inconsistent, behavior between GNU/Linux and macOS
From: Daniel Mendler <mail@HIDDEN>
To: Alan Third <alan@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>,
 48579 <at> debbugs.gnu.org
References: <2d81bff4-21fc-ce96-f1f1-f0bbf60b233e@HIDDEN>
 <837djrklhx.fsf@HIDDEN>
 <ed6f5225-f1b4-fbda-286c-17138e45d63f@HIDDEN>
 <831r9zkkaq.fsf@HIDDEN>
 <e3bd2559-55f4-b944-56dd-532229fee2de@HIDDEN>
 <YKkBepRHimos55d8@HIDDEN>
 <b6620c12-edbf-6af7-2cc8-5ff701bcef5e@HIDDEN>
Message-ID: <92016c65-f70b-486a-3e4b-48664a978c28@HIDDEN>
Date: Sat, 22 May 2021 15:20:56 +0200
MIME-Version: 1.0
In-Reply-To: <b6620c12-edbf-6af7-2cc8-5ff701bcef5e@HIDDEN>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 48579
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

On 5/22/21 3:13 PM, Daniel Mendler wrote:
> On 5/22/21 3:04 PM, Alan Third wrote:
>> On Sat, May 22, 2021 at 02:54:26PM +0200, Daniel Mendler wrote:
>>> But this discussion here seems to be a bit off-track. My point here is
>>> that the current working directory determination on MacOS uses a
>>> heuristic, which is not correct. It incorrectly determines that Emacs
>>> has been launched from the finder or some other Mac GUI application and
>>> therefore changes the directory to the home directory. If Emacs is
>>> indeed started from the GUI, this makes all sense. But this is not the
>>> case here. The TTY heuristic, that Alan described, is insufficient.
>>
>> I can't find any other way, and we had multiple complaints when the
>> behaviour was broken whereas this is the first complaint in the other
>> direction that I've seen.
>>
>> If you find an alternative, please let us know.
> 
> As I wrote, if "--batch" opts out of this, I am happy. I should have
> used "--batch" right away in my program. Since this is what I am doing -
> I am starting a batch background worker job. I just wasn't aware of the
> opt-out. Hopefully the batch setting does not have other unexpected side
> effects.

Hmm, it seems that in my use case the combination of --batch and
--daemon is not working. This means I have to keep using --chdir for the
opt-out. I guess it is expected that --daemon and --batch cannot be
combined? My use case is kind of an edge case.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#48579; Package emacs. Full text available.

Message received at 48579 <at> debbugs.gnu.org:


Received: (at 48579) by debbugs.gnu.org; 22 May 2021 13:15:35 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat May 22 09:15:35 2021
Received: from localhost ([127.0.0.1]:38547 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lkRTb-0000QT-Hy
	for submit <at> debbugs.gnu.org; Sat, 22 May 2021 09:15:35 -0400
Received: from server.qxqx.de ([178.63.65.180]:55751 helo=mail.qxqx.de)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1lkRTZ-0000QG-J9
 for 48579 <at> debbugs.gnu.org; Sat, 22 May 2021 09:15:34 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=qxqx.de;
 s=mail1392553390; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:
 MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender:Reply-To:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=UU8jkSKTPHOfOKrXTFLx5cxzmmG702LCPb/U9wPFhrU=; b=GicjKISKyi8XMPHGfHqVNhcJy7
 QBEx+ogmznzUdLdRRi/gAFaBrkewTGh57pLLLSfegVx6Y5lxr5JOY/WKsIKudW1LnNu9wZagIOISY
 EH0s5LO0mvjNCWv7nW/aca8oleemM0+ymVdfAiAEkQqV7eAXJz02qxgI+36uNqjy+rs8=;
Subject: Re: bug#48579: 28.0.50; Spawning an emacs process using call-process
 results in inconsistent, behavior between GNU/Linux and macOS
To: Eli Zaretskii <eliz@HIDDEN>, Alan Third <alan@HIDDEN>
References: <2d81bff4-21fc-ce96-f1f1-f0bbf60b233e@HIDDEN>
 <YKjzrtZkqFL8lwZp@HIDDEN>
 <9002b376-2ef7-db7d-9d7a-092cda82efe1@HIDDEN>
 <YKkAkmNpUlCPdZxO@HIDDEN> <83wnrqkj6k.fsf@HIDDEN>
From: Daniel Mendler <mail@HIDDEN>
Message-ID: <39fc7951-2515-e4da-b6eb-1df03f560f11@HIDDEN>
Date: Sat, 22 May 2021 15:15:26 +0200
MIME-Version: 1.0
In-Reply-To: <83wnrqkj6k.fsf@HIDDEN>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 48579
Cc: 48579 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

On 5/22/21 3:10 PM, Eli Zaretskii wrote:
>> You can run with "-t", "-nw", "--chdir", "--batch" or "--script" to
>> disable this behaviour.
> 
> That again doesn't necessarily mean you'd be able to tell the cwd of
> the Emacs process at any time during the session.

Eli, I understand the point you are making here. In general you are
right. But the current behavior is good enough for me. Feel free to
close the issue then.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#48579; Package emacs. Full text available.

Message received at 48579 <at> debbugs.gnu.org:


Received: (at 48579) by debbugs.gnu.org; 22 May 2021 13:13:12 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat May 22 09:13:12 2021
Received: from localhost ([127.0.0.1]:38537 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lkRRH-0000MN-TP
	for submit <at> debbugs.gnu.org; Sat, 22 May 2021 09:13:12 -0400
Received: from server.qxqx.de ([178.63.65.180]:37443 helo=mail.qxqx.de)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1lkRRF-0000MA-Jb
 for 48579 <at> debbugs.gnu.org; Sat, 22 May 2021 09:13:09 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=qxqx.de;
 s=mail1392553390; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:
 MIME-Version:Date:Message-ID:From:References:To:Subject:Sender:Reply-To:Cc:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=YzJiFXk5KocUqWJToW5Qtuhf/m09UT4c9/3NjCqrTi8=; b=ZXxjGNQbyOyi2ss0PXBcuKuaGg
 Ay8RMf/ztFWBzzIJSladSNBllQT4DNpp7ixpKgwytiPdrlafsCS9M52uVXdJEurCNYwLi5b8wibFH
 hPTnyj6MsHBgIt0MqmJPbyRfIStw71diu8/V80O0o1dRtewttyYpRbPF35ycsLAOZyaE=;
Subject: Re: bug#48579: 28.0.50; Spawning an emacs process using call-process
 results in inconsistent, behavior between GNU/Linux and macOS
To: Alan Third <alan@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>,
 48579 <at> debbugs.gnu.org
References: <2d81bff4-21fc-ce96-f1f1-f0bbf60b233e@HIDDEN>
 <837djrklhx.fsf@HIDDEN>
 <ed6f5225-f1b4-fbda-286c-17138e45d63f@HIDDEN>
 <831r9zkkaq.fsf@HIDDEN>
 <e3bd2559-55f4-b944-56dd-532229fee2de@HIDDEN>
 <YKkBepRHimos55d8@HIDDEN>
From: Daniel Mendler <mail@HIDDEN>
Message-ID: <b6620c12-edbf-6af7-2cc8-5ff701bcef5e@HIDDEN>
Date: Sat, 22 May 2021 15:13:03 +0200
MIME-Version: 1.0
In-Reply-To: <YKkBepRHimos55d8@HIDDEN>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 48579
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

On 5/22/21 3:04 PM, Alan Third wrote:
> On Sat, May 22, 2021 at 02:54:26PM +0200, Daniel Mendler wrote:
>> But this discussion here seems to be a bit off-track. My point here is
>> that the current working directory determination on MacOS uses a
>> heuristic, which is not correct. It incorrectly determines that Emacs
>> has been launched from the finder or some other Mac GUI application and
>> therefore changes the directory to the home directory. If Emacs is
>> indeed started from the GUI, this makes all sense. But this is not the
>> case here. The TTY heuristic, that Alan described, is insufficient.
> 
> I can't find any other way, and we had multiple complaints when the
> behaviour was broken whereas this is the first complaint in the other
> direction that I've seen.
> 
> If you find an alternative, please let us know.

As I wrote, if "--batch" opts out of this, I am happy. I should have
used "--batch" right away in my program. Since this is what I am doing -
I am starting a batch background worker job. I just wasn't aware of the
opt-out. Hopefully the batch setting does not have other unexpected side
effects.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#48579; Package emacs. Full text available.

Message received at 48579 <at> debbugs.gnu.org:


Received: (at 48579) by debbugs.gnu.org; 22 May 2021 13:11:08 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat May 22 09:11:08 2021
Received: from localhost ([127.0.0.1]:38533 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lkRPI-0000JQ-Fw
	for submit <at> debbugs.gnu.org; Sat, 22 May 2021 09:11:08 -0400
Received: from eggs.gnu.org ([209.51.188.92]:33482)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lkRPD-0000Ih-WD
 for 48579 <at> debbugs.gnu.org; Sat, 22 May 2021 09:11:07 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:59210)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lkRP8-0004D5-Bj; Sat, 22 May 2021 09:10:58 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:1209
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1lkRP7-00059j-Kv; Sat, 22 May 2021 09:10:58 -0400
Date: Sat, 22 May 2021 16:10:59 +0300
Message-Id: <83wnrqkj6k.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Alan Third <alan@HIDDEN>
In-Reply-To: <YKkAkmNpUlCPdZxO@HIDDEN> (message from Alan Third on Sat, 22
 May 2021 14:01:06 +0100)
Subject: Re: bug#48579: 28.0.50; Spawning an emacs process using call-process
 results in inconsistent, behavior between GNU/Linux and macOS
References: <2d81bff4-21fc-ce96-f1f1-f0bbf60b233e@HIDDEN>
 <YKjzrtZkqFL8lwZp@HIDDEN>
 <9002b376-2ef7-db7d-9d7a-092cda82efe1@HIDDEN>
 <YKkAkmNpUlCPdZxO@HIDDEN>
X-Spam-Score: -1.6 (-)
X-Debbugs-Envelope-To: 48579
Cc: mail@HIDDEN, alan@HIDDEN, 48579 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.6 (--)

> Date: Sat, 22 May 2021 14:01:06 +0100
> From: Alan Third <alan@HIDDEN>
> Cc: Eli Zaretskii <eliz@HIDDEN>, 48579 <at> debbugs.gnu.org
> 
> > 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.

That again doesn't necessarily mean you'd be able to tell the cwd of
the Emacs process at any time during the session.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#48579; Package emacs. Full text available.

Message received at 48579 <at> debbugs.gnu.org:


Received: (at 48579) by debbugs.gnu.org; 22 May 2021 13:10:58 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat May 22 09:10:58 2021
Received: from localhost ([127.0.0.1]:38529 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lkRP8-0000IZ-8J
	for submit <at> debbugs.gnu.org; Sat, 22 May 2021 09:10:58 -0400
Received: from server.qxqx.de ([178.63.65.180]:48953 helo=mail.qxqx.de)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1lkRP3-0000IJ-BO
 for 48579 <at> debbugs.gnu.org; Sat, 22 May 2021 09:10:57 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=qxqx.de;
 s=mail1392553390; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:
 MIME-Version:Date:Message-ID:From:References:To:Subject:Sender:Reply-To:Cc:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=ACinFEsjo8ND6W83IdNDqXvRcldQzMUfMc9oEO/w8pw=; b=l6oYM5nN/ghpI7x1rmd2kSk0pt
 F1IJRFHqRBN3CGmOd/kB60uO3kM0G55R8+YFGMRq9PL+4jTTHn9ruJyguDmWQUNvXj7KXMCO8H+wW
 HrN2mO/xI9PY2hTLH0G0APm8n8md7HxT3H3vJPPwoqmVmiBZ4ULns9zcQVefIrBNmCdU=;
Subject: Re: bug#48579: 28.0.50; Spawning an emacs process using call-process
 results in inconsistent, behavior between GNU/Linux and macOS
To: Alan Third <alan@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>,
 48579 <at> debbugs.gnu.org
References: <2d81bff4-21fc-ce96-f1f1-f0bbf60b233e@HIDDEN>
 <YKjzrtZkqFL8lwZp@HIDDEN>
 <9002b376-2ef7-db7d-9d7a-092cda82efe1@HIDDEN>
 <YKkAkmNpUlCPdZxO@HIDDEN>
From: Daniel Mendler <mail@HIDDEN>
Message-ID: <e5e5604c-1182-f006-deae-459d3d019bd0@HIDDEN>
Date: Sat, 22 May 2021 15:10:46 +0200
MIME-Version: 1.0
In-Reply-To: <YKkAkmNpUlCPdZxO@HIDDEN>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 48579
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

On 5/22/21 3:01 PM, Alan Third wrote:
>> 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.

I am currently using "--chdir" to work around this. If "--batch" also
opts out of this behavior I am actually happy, as I wrote in an earlier
mail. I am sorry that I could not test this, since I do not have a Mac
available.

For my purposes using "--batch" is probably the correct setting and I
should have used that right away. It is kind of unclear to me what other
settings are affected by "--batch"? It sets `noninteractive` for example.

Feel free to close this bug report then!




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#48579; Package emacs. Full text available.

Message received at 48579 <at> debbugs.gnu.org:


Received: (at 48579) by debbugs.gnu.org; 22 May 2021 13:09:15 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat May 22 09:09:15 2021
Received: from localhost ([127.0.0.1]:38525 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lkRNS-0000Fw-Qn
	for submit <at> debbugs.gnu.org; Sat, 22 May 2021 09:09:15 -0400
Received: from eggs.gnu.org ([209.51.188.92]:33280)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lkRNQ-0000Fj-K8
 for 48579 <at> debbugs.gnu.org; Sat, 22 May 2021 09:09:14 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:59192)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lkRNK-0003et-PV; Sat, 22 May 2021 09:09:06 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:1093
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1lkRNK-0004zv-2I; Sat, 22 May 2021 09:09:06 -0400
Date: Sat, 22 May 2021 16:09:05 +0300
Message-Id: <83y2c6kj9q.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Daniel Mendler <mail@HIDDEN>
In-Reply-To: <e3bd2559-55f4-b944-56dd-532229fee2de@HIDDEN> (message
 from Daniel Mendler on Sat, 22 May 2021 14:54:26 +0200)
Subject: Re: bug#48579: 28.0.50; Spawning an emacs process using call-process
 results in inconsistent, behavior between GNU/Linux and macOS
References: <2d81bff4-21fc-ce96-f1f1-f0bbf60b233e@HIDDEN>
 <837djrklhx.fsf@HIDDEN>
 <ed6f5225-f1b4-fbda-286c-17138e45d63f@HIDDEN>
 <831r9zkkaq.fsf@HIDDEN>
 <e3bd2559-55f4-b944-56dd-532229fee2de@HIDDEN>
X-Spam-Score: -1.6 (-)
X-Debbugs-Envelope-To: 48579
Cc: alan@HIDDEN, 48579 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.6 (--)

> Cc: alan@HIDDEN, 48579 <at> debbugs.gnu.org
> From: Daniel Mendler <mail@HIDDEN>
> Date: Sat, 22 May 2021 14:54:26 +0200
> 
> > Right, no roadblocks.  And Emacs does determine that, for its own
> > purposes, on all platforms.  It just doesn't expose that to Lisp.
> 
> This statement does not seem correct to me. There is a default-directory
> which I can access in the initial *scratch* buffer. Something is exposed
> here.

We are mis-communicating.  All I'm saying is that this
default-directory is not (and doesn't have to be) the cwd of the Emacs
process.

> But this discussion here seems to be a bit off-track. My point here is
> that the current working directory determination on MacOS uses a
> heuristic, which is not correct. It incorrectly determines that Emacs
> has been launched from the finder or some other Mac GUI application and
> therefore changes the directory to the home directory. If Emacs is
> indeed started from the GUI, this makes all sense. But this is not the
> case here. The TTY heuristic, that Alan described, is insufficient.

I don't see why it matters what logic Emacs follows on macOS when its
starts, wrt the cwd of the Emacs process.

If you want to make sure that the default-directory of *scratch* is
the directory where Emacs was started, we could add such a feature (it
doesn't exists now, and relying on what you see on GNU/Linux means you
are relying on one particular implementation).  However, even if we do
introduce such a feature, that still won't tell you anything about the
cwd of the Emacs process.  If this latter aspect is what you really
care about, you will have to explain the rationale, because I don't
see how it could be important.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#48579; Package emacs. Full text available.

Message received at 48579 <at> debbugs.gnu.org:


Received: (at 48579) by debbugs.gnu.org; 22 May 2021 13:05:09 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat May 22 09:05:09 2021
Received: from localhost ([127.0.0.1]:38521 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lkRJV-0008RS-AN
	for submit <at> debbugs.gnu.org; Sat, 22 May 2021 09:05:09 -0400
Received: from outbound.soverin.net ([116.202.65.218]:35985)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <alan@HIDDEN>) id 1lkRJT-0008Pp-GB
 for 48579 <at> debbugs.gnu.org; Sat, 22 May 2021 09:05:08 -0400
Received: from smtp.soverin.net (unknown [10.10.3.28])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
 (No client certificate requested)
 by outbound.soverin.net (Postfix) with ESMTPS id CF3D16008B;
 Sat, 22 May 2021 13:05:01 +0000 (UTC)
Received: from smtp.soverin.net (smtp.soverin.net [159.69.232.142]) by
 soverin.net
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=idiocy.org; s=soverin;
 t=1621688701; bh=TZvZui5fQ3AX+t9ntHbhS1QdlBjTWrxWr7osuYFwups=;
 h=Date:From:To:Cc:Subject:References:In-Reply-To:From;
 b=YGhumzQw/EfDoeXK6heca6QHvko34Icq0JisFmB8ZJUGlTkTkesF/Tc5tdBkRlVIM
 zBguFVbYDrgwDPQfKKp+Ero6GFHVLeUwXIiRdIIN7UOX2rhxVzOzbLyjlKWUMji43C
 voZW6fragFoXHaievWzhF/4BVJIM9GOvN/m9P+nLQZo+3paKH0P5noHsurUtDAGP7n
 gy4APbEdnsA+s0jfHKn4G7IOCEFdXXxFY6CgL1D/JrDhupHHrsgMEEkfXke20fhGBH
 UeCsomLzKeB49u8McrztVy2S98QvPKltbBQTgV+GV0R49TRCpOIVmeyiczHugZT9Rf
 QBdOu1mN2S2Kg==
Received: from alan by faroe.holly.idiocy.org with local (Exim 4.94.2)
 (envelope-from <alan@HIDDEN>)
 id 1lkRJK-0007pc-6G; Sat, 22 May 2021 14:04:58 +0100
Date: Sat, 22 May 2021 14:04:58 +0100
From: Alan Third <alan@HIDDEN>
To: Daniel Mendler <mail@HIDDEN>
Subject: Re: bug#48579: 28.0.50; Spawning an emacs process using call-process
 results in inconsistent, behavior between GNU/Linux and macOS
Message-ID: <YKkBepRHimos55d8@HIDDEN>
Mail-Followup-To: Alan Third <alan@HIDDEN>,
 Daniel Mendler <mail@HIDDEN>,
 Eli Zaretskii <eliz@HIDDEN>, 48579 <at> debbugs.gnu.org
References: <2d81bff4-21fc-ce96-f1f1-f0bbf60b233e@HIDDEN>
 <837djrklhx.fsf@HIDDEN>
 <ed6f5225-f1b4-fbda-286c-17138e45d63f@HIDDEN>
 <831r9zkkaq.fsf@HIDDEN>
 <e3bd2559-55f4-b944-56dd-532229fee2de@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <e3bd2559-55f4-b944-56dd-532229fee2de@HIDDEN>
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 48579
Cc: Eli Zaretskii <eliz@HIDDEN>, 48579 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Sat, May 22, 2021 at 02:54:26PM +0200, Daniel Mendler wrote:
> But this discussion here seems to be a bit off-track. My point here is
> that the current working directory determination on MacOS uses a
> heuristic, which is not correct. It incorrectly determines that Emacs
> has been launched from the finder or some other Mac GUI application and
> therefore changes the directory to the home directory. If Emacs is
> indeed started from the GUI, this makes all sense. But this is not the
> case here. The TTY heuristic, that Alan described, is insufficient.

I can't find any other way, and we had multiple complaints when the
behaviour was broken whereas this is the first complaint in the other
direction that I've seen.

If you find an alternative, please let us know.
-- 
Alan Third




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#48579; Package emacs. Full text available.

Message received at 48579 <at> debbugs.gnu.org:


Received: (at 48579) by debbugs.gnu.org; 22 May 2021 13:01:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat May 22 09:01:19 2021
Received: from localhost ([127.0.0.1]:38517 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lkRFm-0008GF-Ob
	for submit <at> debbugs.gnu.org; Sat, 22 May 2021 09:01:18 -0400
Received: from outbound.soverin.net ([116.202.65.218]:50885)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <alan@HIDDEN>) id 1lkRFj-0008Fz-Ht
 for 48579 <at> debbugs.gnu.org; Sat, 22 May 2021 09:01:17 -0400
Received: from smtp.soverin.net (unknown [10.10.3.24])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
 (No client certificate requested)
 by outbound.soverin.net (Postfix) with ESMTPS id C24366008B;
 Sat, 22 May 2021 13:01:09 +0000 (UTC)
Received: from smtp.soverin.net (smtp.soverin.net [159.69.232.138]) by
 soverin.net
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=idiocy.org; s=soverin;
 t=1621688469; bh=xjJvHRm7zsMOMIIdw28011wmT6783Bc/hUw6zLN9ruw=;
 h=Date:From:To:Cc:Subject:References:In-Reply-To:From;
 b=kPV/+4OAQ9PmLZSob1qfb2niIU4a8vQueFF9r2FfVyQ5D1eCo2rDxDO4uSrWfcm4U
 Ud75Yo/+EyR0ifnEDLYPT4FuSDqJ7o4DMBzOxl2HWn18d+v+qMzTF00HqzqJs89M1r
 Tp/Jn08d7Yoh6TOX1YUHHl7vPOznQoziJsLbyby3Hhx4/K5U9t9vtMJ4hiaoI41KHC
 Nbgg2zxqLpqPzh9yrQnk6dZESiFKDn3J7wF0+RLz2F99rxxSDBVvDrSiku2gqNldHa
 heskoVmFdRUjMsy/Iqt7PGLjd4I8EdNENXwWAGDgnxVW60gyh0+dnx4Y+GjRK+FoLa
 5dqmfJ1GsjxlA==
Received: from alan by faroe.holly.idiocy.org with local (Exim 4.94.2)
 (envelope-from <alan@HIDDEN>)
 id 1lkRFa-0007p7-Hh; Sat, 22 May 2021 14:01:06 +0100
Date: Sat, 22 May 2021 14:01:06 +0100
From: Alan Third <alan@HIDDEN>
To: Daniel Mendler <mail@HIDDEN>
Subject: Re: bug#48579: 28.0.50; Spawning an emacs process using call-process
 results in inconsistent, behavior between GNU/Linux and macOS
Message-ID: <YKkAkmNpUlCPdZxO@HIDDEN>
Mail-Followup-To: Alan Third <alan@HIDDEN>,
 Daniel Mendler <mail@HIDDEN>,
 Eli Zaretskii <eliz@HIDDEN>, 48579 <at> debbugs.gnu.org
References: <2d81bff4-21fc-ce96-f1f1-f0bbf60b233e@HIDDEN>
 <YKjzrtZkqFL8lwZp@HIDDEN>
 <9002b376-2ef7-db7d-9d7a-092cda82efe1@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <9002b376-2ef7-db7d-9d7a-092cda82efe1@HIDDEN>
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 48579
Cc: Eli Zaretskii <eliz@HIDDEN>, 48579 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

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




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#48579; Package emacs. Full text available.

Message received at 48579 <at> debbugs.gnu.org:


Received: (at 48579) by debbugs.gnu.org; 22 May 2021 12:54:36 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat May 22 08:54:36 2021
Received: from localhost ([127.0.0.1]:38505 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lkR9H-00084u-WF
	for submit <at> debbugs.gnu.org; Sat, 22 May 2021 08:54:36 -0400
Received: from server.qxqx.de ([178.63.65.180]:33019 helo=mail.qxqx.de)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1lkR9F-00084g-TF
 for 48579 <at> debbugs.gnu.org; Sat, 22 May 2021 08:54:34 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=qxqx.de;
 s=mail1392553390; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:
 MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender:Reply-To:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=cAwFOdtnaYfps9DoW7rhkdwEWg1W8Bm8O2bbZ7QJ9cU=; b=b0HFC7l4Hr7Lpj7ZUzUpgjcieX
 lpnCHOiHvI8ACB5kBy7hH+LbDSZipbTPE26K4YowPLzJejH+oPUOt8bDrynoPFTm1jdox1mlfj04R
 czfMu9ueb8A9ecfpgpGZzjpCjbFmX5ixeTohkNy+gIkOukCzRQY26f2BDy/ixOLuXlbk=;
Subject: Re: bug#48579: 28.0.50; Spawning an emacs process using call-process
 results in inconsistent, behavior between GNU/Linux and macOS
To: Eli Zaretskii <eliz@HIDDEN>
References: <2d81bff4-21fc-ce96-f1f1-f0bbf60b233e@HIDDEN>
 <837djrklhx.fsf@HIDDEN>
 <ed6f5225-f1b4-fbda-286c-17138e45d63f@HIDDEN>
 <831r9zkkaq.fsf@HIDDEN>
From: Daniel Mendler <mail@HIDDEN>
Message-ID: <e3bd2559-55f4-b944-56dd-532229fee2de@HIDDEN>
Date: Sat, 22 May 2021 14:54:26 +0200
MIME-Version: 1.0
In-Reply-To: <831r9zkkaq.fsf@HIDDEN>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 48579
Cc: alan@HIDDEN, 48579 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

On 5/22/21 2:46 PM, Eli Zaretskii wrote:
>> I am aware that the file visiting buffers have a different
>> default-directory. However the initial scratch buffer should inherit the
>> current working directory of the parent process.
> 
> Like I said: this last expectation is wrong in Emacs.  The cwd of the
> Emacs process is carefully concealed from Lisp, by design.  My advice
> is not to make the assumption you do, because Emacs doesn't promise
> you it will follow it.
>
>> There is no technical roadblock preventing Emacs from determining the
>> current directory (at least on Unixes).
> 
> Right, no roadblocks.  And Emacs does determine that, for its own
> purposes, on all platforms.  It just doesn't expose that to Lisp.

This statement does not seem correct to me. There is a default-directory
which I can access in the initial *scratch* buffer. Something is exposed
here. Why is the default-directory not nil then?

Seriously, what is the justification for this? If Emacs determines the
current working directory on all platforms, why does it not guarantee
that the initial *scratch* buffer sees this directory?

But this discussion here seems to be a bit off-track. My point here is
that the current working directory determination on MacOS uses a
heuristic, which is not correct. It incorrectly determines that Emacs
has been launched from the finder or some other Mac GUI application and
therefore changes the directory to the home directory. If Emacs is
indeed started from the GUI, this makes all sense. But this is not the
case here. The TTY heuristic, that Alan described, is insufficient.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#48579; Package emacs. Full text available.

Message received at 48579 <at> debbugs.gnu.org:


Received: (at 48579) by debbugs.gnu.org; 22 May 2021 12:47:54 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat May 22 08:47:54 2021
Received: from localhost ([127.0.0.1]:38500 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lkR2o-0007vZ-68
	for submit <at> debbugs.gnu.org; Sat, 22 May 2021 08:47:54 -0400
Received: from eggs.gnu.org ([209.51.188.92]:57786)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lkR2i-0007vJ-FF
 for 48579 <at> debbugs.gnu.org; Sat, 22 May 2021 08:47:53 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:58920)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lkR2c-0004ny-II; Sat, 22 May 2021 08:47:42 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3764
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1lkR2b-0007cG-8K; Sat, 22 May 2021 08:47:42 -0400
Date: Sat, 22 May 2021 15:47:43 +0300
Message-Id: <83zgwnj5ow.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Daniel Mendler <mail@HIDDEN>
In-Reply-To: <8865a048-d989-e08b-80c9-0d793b85cf5a@HIDDEN> (message
 from Daniel Mendler on Sat, 22 May 2021 14:41:22 +0200)
Subject: Re: bug#48579: 28.0.50; Spawning an emacs process using call-process
 results in inconsistent, behavior between GNU/Linux and macOS
References: <2d81bff4-21fc-ce96-f1f1-f0bbf60b233e@HIDDEN>
 <YKjzrtZkqFL8lwZp@HIDDEN>
 <9002b376-2ef7-db7d-9d7a-092cda82efe1@HIDDEN>
 <834kevkl4b.fsf@HIDDEN>
 <8865a048-d989-e08b-80c9-0d793b85cf5a@HIDDEN>
X-Spam-Score: -1.5 (-)
X-Debbugs-Envelope-To: 48579
Cc: alan@HIDDEN, 48579 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.6 (--)

> Cc: alan@HIDDEN, 48579 <at> debbugs.gnu.org
> From: Daniel Mendler <mail@HIDDEN>
> Date: Sat, 22 May 2021 14:41:22 +0200
> 
> I am not talking about a random directory of some random buffer. Of
> course these buffers have default-directories depending on if a file is
> visited and so on. I am talking about the default-directory of the
> initial *scratch* buffer, which runs the script loaded directly after
> launch. This is relevant in case you want to start worker jobs executing
> some code asynchronously for example, related to the current discussion
> on the mailing list (emacsclient in elisp).

You should use absolute file names.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#48579; Package emacs. Full text available.

Message received at 48579 <at> debbugs.gnu.org:


Received: (at 48579) by debbugs.gnu.org; 22 May 2021 12:47:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat May 22 08:47:03 2021
Received: from localhost ([127.0.0.1]:38497 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lkR1y-0007uX-QE
	for submit <at> debbugs.gnu.org; Sat, 22 May 2021 08:47:03 -0400
Received: from eggs.gnu.org ([209.51.188.92]:57692)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lkR1w-0007u3-SI
 for 48579 <at> debbugs.gnu.org; Sat, 22 May 2021 08:47:01 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:58914)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lkR1r-0004bx-JZ; Sat, 22 May 2021 08:46:55 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3709
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1lkR1p-0007Zf-I5; Sat, 22 May 2021 08:46:55 -0400
Date: Sat, 22 May 2021 15:46:53 +0300
Message-Id: <831r9zkkaq.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Daniel Mendler <mail@HIDDEN>
In-Reply-To: <ed6f5225-f1b4-fbda-286c-17138e45d63f@HIDDEN> (message
 from Daniel Mendler on Sat, 22 May 2021 14:37:35 +0200)
Subject: Re: bug#48579: 28.0.50; Spawning an emacs process using call-process
 results in inconsistent, behavior between GNU/Linux and macOS
References: <2d81bff4-21fc-ce96-f1f1-f0bbf60b233e@HIDDEN>
 <837djrklhx.fsf@HIDDEN>
 <ed6f5225-f1b4-fbda-286c-17138e45d63f@HIDDEN>
X-Spam-Score: -1.6 (-)
X-Debbugs-Envelope-To: 48579
Cc: alan@HIDDEN, 48579 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.6 (--)

> Cc: alan@HIDDEN, 48579 <at> debbugs.gnu.org
> From: Daniel Mendler <mail@HIDDEN>
> Date: Sat, 22 May 2021 14:37:35 +0200
> 
> > If this is what you think, then your concept of the default-directory
> > is in direct contradiction with how Emacs works.  The cwd of the Emacs
> > process is immaterial, and actually not even easily visible inside
> > Emacs.  When a buffer visits a file, Emacs makes a point of behaving
> > like that file's directory was its cwd.  For other buffers, my
> > suggestion is to consider their default-directory to be indeterminate,
> > and if you need it to have a specified value, you should force that by
> > calling 'cd' or setting default-directory explicitly.  Anything else
> > is bound to trip you some day, because it simply isn't how Emacs was
> > designed to behave.
> 
> I am aware that the file visiting buffers have a different
> default-directory. However the initial scratch buffer should inherit the
> current working directory of the parent process.

Like I said: this last expectation is wrong in Emacs.  The cwd of the
Emacs process is carefully concealed from Lisp, by design.  My advice
is not to make the assumption you do, because Emacs doesn't promise
you it will follow it.

> I don't see why some "indeterminate" or "undefined" behavior is
> justified here.

It is justified because that's how Emacs was designed.

> There is no technical roadblock preventing Emacs from determining the
> current directory (at least on Unixes).

Right, no roadblocks.  And Emacs does determine that, for its own
purposes, on all platforms.  It just doesn't expose that to Lisp.

> The problem is that the Mac Emacs port changes the directory
> according to its own standards.

I see no problem here.  There's nothing wrong with that behavior.

> Why do you call this "indeterminate", "undefined" or "random" behavior?
> Are there other examples where buffers have random directories?

They aren't random.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#48579; Package emacs. Full text available.

Message received at 48579 <at> debbugs.gnu.org:


Received: (at 48579) by debbugs.gnu.org; 22 May 2021 12:45:49 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat May 22 08:45:49 2021
Received: from localhost ([127.0.0.1]:38492 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lkR0n-0007s4-1b
	for submit <at> debbugs.gnu.org; Sat, 22 May 2021 08:45:49 -0400
Received: from mail-ot1-f54.google.com ([209.85.210.54]:39756)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rajkrishnan1996@HIDDEN>) id 1lkPvU-0003z3-0k
 for 48579 <at> debbugs.gnu.org; Sat, 22 May 2021 07:36:17 -0400
Received: by mail-ot1-f54.google.com with SMTP id
 d25-20020a0568300459b02902f886f7dd43so20492901otc.6
 for <48579 <at> debbugs.gnu.org>; Sat, 22 May 2021 04:36:15 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:references:in-reply-to:from:date:message-id:subject:to
 :cc; bh=XUp5JJbTtrpsKUGmmazIPeagf2M8wKfh9aWoWiIuroo=;
 b=YzOePNt3JDdKl76gso+0KPeUK+0X8QyXPJWqqPxhpvui9LoeEyZeXJXzRZL5VX9f12
 W3o9/guNRBAyr4UHs6F0yzHsEkPdEds1MfQ2xSejR/49vogiY9AzKWydfZ7FtVheoinQ
 0IB63nyUa2AXHzXKHJxCzBHirM/XXv1OgbAsuOp+nxFQF/YXNIppQ/jGGykGeiJsMhA/
 BL+UtitGoQ1hzlaGvGuzGIgk0cXdGt1G2VZxUng7HE6ItK2pGfDZXTM14hxh/05AYnqV
 H3ix9nl8bZy4L4UZGlC0AlNicQLLSSy+krQ+tgDTgk3cVx1VGUkRBn2f/yRgMicsfD9m
 tLcg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:references:in-reply-to:from:date
 :message-id:subject:to:cc;
 bh=XUp5JJbTtrpsKUGmmazIPeagf2M8wKfh9aWoWiIuroo=;
 b=a3133koSp209Agfwwmj5XkHcAmyYgWi8cgCcj7q+RdX6dKOOd/+4tSh/7qmvCiJ9nU
 0sv91REh0uS1K+3fhpjG/ejIdO8K8t/JKC/t9UgFU7eMLSaF2N6Jmdmb2PGNKH95XS2R
 PSAQLvPvJ6oXvHkF1C4GgEBXueCYn53/+qBcwlDezQJkzu3Emiq6P2BrlpkOTmJBBKYo
 QdWudgGh2D3ZTvt9uXH25ofU/mYYUvig/uef9tmahXBJd0iFPILaJ30XCUvp6rlnTL2X
 7K2+WbQ+lJ0Lx2W2IUK++AENvNIglo51THbvugOLsRqp0rOLKXE5/KoRjfmtrQNd9K87
 /Aaw==
X-Gm-Message-State: AOAM532n5cHW2azDYOyXkEJonmAC5Q82PO0N4XOjPZpwYAVdPembu5uM
 +DQPuBESFAPkdNRGl9o2XpbH7wuv/YOVxjP+7j9uEeK+59Y=
X-Google-Smtp-Source: ABdhPJxJSQ3WZsZp3e2cqJB+AdfbRCxwL2NugcroGRcP+B8WaFLEECWtrcejVcB0pd7NeSiUYP6jMXm68boG1AYmtyo=
X-Received: by 2002:a05:6830:1155:: with SMTP id
 x21mr11600888otq.303.1621683370351; 
 Sat, 22 May 2021 04:36:10 -0700 (PDT)
MIME-Version: 1.0
References: <CAOotCtPMnHpVmetVs+EncvtqCsVuaSwNkuEsvMKAqBkhGJZygw@HIDDEN>
 <YKjcSA/E3hO+i8Z7@HIDDEN> <83a6onkq7s.fsf@HIDDEN>
In-Reply-To: <83a6onkq7s.fsf@HIDDEN>
From: Raj Krishnan <rajkrishnan1996@HIDDEN>
Date: Sat, 22 May 2021 17:05:58 +0530
Message-ID: <CAOotCtMkffDtDsae6-CbCzpCy-hd=ia0KqqtkGur2W2z3V0zUw@HIDDEN>
Subject: Re: bug#48579: 28.0.50; Spawning an emacs process using call-process
 results in inconsistent behavior between GNU/Linux and macOS
To: Eli Zaretskii <eliz@HIDDEN>
Content-Type: multipart/alternative; boundary="0000000000003a5ea205c2e995e8"
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 48579
X-Mailman-Approved-At: Sat, 22 May 2021 08:45:45 -0400
Cc: Alan Third <alan@HIDDEN>, 48579 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

--0000000000003a5ea205c2e995e8
Content-Type: text/plain; charset="UTF-8"

Thanks Alan, Eli!


Adam's comment seems to be the root cause of this.

One extra dot on your point Eli: this happens in case we run the
command in a regular buffer as well, not just in the scratch buffer.

Explicitly specifying the directory we expect to be in seems cleaner,
and we shall pass along a chdir flag to call-process, in order
to switch directories.

On Sat, May 22, 2021, 4:09 PM Eli Zaretskii <eliz@HIDDEN> wrote:

> > Date: Sat, 22 May 2021 11:26:16 +0100
> > From: Alan Third <alan@HIDDEN>
> > Cc: 48579 <at> debbugs.gnu.org
> >
> > > 5. Behavior on GNU/Linux: The directory matches the value shown in (2)
> > >    Behavior on macOS: The default directory has changed to the user's
> > >    home directory
> > >
> > > The behavior was spotted when we noticed inconsistent behavior in
> > > [[https://github.com/minad/affe][affe.el]], which was subsequently
> > > reproduced using =emacs -Q=
> >
> > The NS port checks if it's connected to a TTY when it starts, and if
> > not assumes it's being run from finder and so sets the starting
> > directory to something useful ($HOME), instead of / or whatever it
> > defaults to.
>
> I think any Lisp program that assumes something about the directory of
> the *scratch* buffer based on where Emacs was invoked is buggy.  E.g.,
> on MS-Windows one can specify a starting directory for Emacs via the
> properties of the Emacs desktop icon, and Lisp programs have no way of
> knowing where that is.
>
> Lisp programs that want rely on the value of the default directory
> should explicitly call 'cd' to change to that directory (passing it
> via command-line arguments if necessary, as it probably is in the case
> in point).
>
> Bottom line: I don't see any Emacs bug here.
>

--0000000000003a5ea205c2e995e8
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto">Thanks Alan, Eli!<div dir=3D"auto"><br></div><div dir=3D"=
auto"><br><div dir=3D"auto">Adam&#39;s comment seems to be the root cause o=
f this.<br></div><div dir=3D"auto"><br></div><div dir=3D"auto">One extra do=
t on your point Eli: this happens in case we run the</div><div dir=3D"auto"=
>command in a regular buffer as well, not just in the scratch buffer.</div>=
<div dir=3D"auto"><br></div><div dir=3D"auto">Explicitly specifying the dir=
ectory we expect to be in seems cleaner,</div><div dir=3D"auto">and we shal=
l pass along a chdir flag to call-process, in order</div><div dir=3D"auto">=
to switch directories.</div><div dir=3D"auto"><br></div><div class=3D"gmail=
_quote" dir=3D"auto"><div dir=3D"ltr" class=3D"gmail_attr">On Sat, May 22, =
2021, 4:09 PM Eli Zaretskii &lt;<a href=3D"mailto:eliz@HIDDEN">eliz@HIDDEN=
g</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin=
:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">&gt; Date: Sat, 22=
 May 2021 11:26:16 +0100<br>
&gt; From: Alan Third &lt;<a href=3D"mailto:alan@HIDDEN" target=3D"_bla=
nk" rel=3D"noreferrer">alan@HIDDEN</a>&gt;<br>
&gt; Cc: <a href=3D"mailto:48579 <at> debbugs.gnu.org" target=3D"_blank" rel=3D"=
noreferrer">48579 <at> debbugs.gnu.org</a><br>
&gt; <br>
&gt; &gt; 5. Behavior on GNU/Linux: The directory matches the value shown i=
n (2)<br>
&gt; &gt;=C2=A0 =C2=A0 Behavior on macOS: The default directory has changed=
 to the user&#39;s<br>
&gt; &gt;=C2=A0 =C2=A0 home directory<br>
&gt; &gt; <br>
&gt; &gt; The behavior was spotted when we noticed inconsistent behavior in=
<br>
&gt; &gt; [[<a href=3D"https://github.com/minad/affe%5D%5Baffe.el%5D" rel=
=3D"noreferrer noreferrer" target=3D"_blank">https://github.com/minad/affe]=
[affe.el]</a>], which was subsequently<br>
&gt; &gt; reproduced using =3Demacs -Q=3D<br>
&gt; <br>
&gt; The NS port checks if it&#39;s connected to a TTY when it starts, and =
if<br>
&gt; not assumes it&#39;s being run from finder and so sets the starting<br=
>
&gt; directory to something useful ($HOME), instead of / or whatever it<br>
&gt; defaults to.<br>
<br>
I think any Lisp program that assumes something about the directory of<br>
the *scratch* buffer based on where Emacs was invoked is buggy.=C2=A0 E.g.,=
<br>
on MS-Windows one can specify a starting directory for Emacs via the<br>
properties of the Emacs desktop icon, and Lisp programs have no way of<br>
knowing where that is.<br>
<br>
Lisp programs that want rely on the value of the default directory<br>
should explicitly call &#39;cd&#39; to change to that directory (passing it=
<br>
via command-line arguments if necessary, as it probably is in the case<br>
in point).<br>
<br>
Bottom line: I don&#39;t see any Emacs bug here.<br>
</blockquote></div></div></div>

--0000000000003a5ea205c2e995e8--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#48579; Package emacs. Full text available.

Message received at 48579 <at> debbugs.gnu.org:


Received: (at 48579) by debbugs.gnu.org; 22 May 2021 12:41:31 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat May 22 08:41:31 2021
Received: from localhost ([127.0.0.1]:38487 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lkQwc-0007ly-QT
	for submit <at> debbugs.gnu.org; Sat, 22 May 2021 08:41:31 -0400
Received: from server.qxqx.de ([178.63.65.180]:53709 helo=mail.qxqx.de)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1lkQwa-0007ll-TM
 for 48579 <at> debbugs.gnu.org; Sat, 22 May 2021 08:41:29 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=qxqx.de;
 s=mail1392553390; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:
 MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender:Reply-To:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=9qhCMl1QVYLlJftFWw9l3wiIOJPCYBbysgMyXbn+JIw=; b=HP1IJUS2LAPidEZ76DFe/YO8l2
 uCBfJh0T4Q3uBFakqAummVXurirgSPkHlHyM3ijVXP0DUCGB43KKG+JS32POwwp9WY3iii+9ADVFJ
 W+gF8+s6Vn2XREG2lngVAEx1chIQI2R/89LINDgGJYAh5/L2vj/MkW+2CJ8YpYvnL5x0=;
Subject: Re: bug#48579: 28.0.50; Spawning an emacs process using call-process
 results in inconsistent, behavior between GNU/Linux and macOS
To: Eli Zaretskii <eliz@HIDDEN>
References: <2d81bff4-21fc-ce96-f1f1-f0bbf60b233e@HIDDEN>
 <YKjzrtZkqFL8lwZp@HIDDEN>
 <9002b376-2ef7-db7d-9d7a-092cda82efe1@HIDDEN>
 <834kevkl4b.fsf@HIDDEN>
From: Daniel Mendler <mail@HIDDEN>
Message-ID: <8865a048-d989-e08b-80c9-0d793b85cf5a@HIDDEN>
Date: Sat, 22 May 2021 14:41:22 +0200
MIME-Version: 1.0
In-Reply-To: <834kevkl4b.fsf@HIDDEN>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 48579
Cc: alan@HIDDEN, 48579 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

On 5/22/21 2:29 PM, Eli Zaretskii wrote:
>> From: Daniel Mendler <mail@HIDDEN>
>> Date: Sat, 22 May 2021 14:14:53 +0200
>>
>>> 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, 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?
> 
> That won't help.  The initial directory in which Emacs starts can be
> controlled that way, but that's not what you will see in some random
> buffer's default-directory.  It is completely OK for Emacs to change
> its cwd, as far as the OS is concerned, after it was started, because
> that directory doesn't affect how Emacs works.

I am not talking about a random directory of some random buffer. Of
course these buffers have default-directories depending on if a file is
visited and so on. I am talking about the default-directory of the
initial *scratch* buffer, which runs the script loaded directly after
launch. This is relevant in case you want to start worker jobs executing
some code asynchronously for example, related to the current discussion
on the mailing list (emacsclient in elisp).

Daniel




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#48579; Package emacs. Full text available.

Message received at 48579 <at> debbugs.gnu.org:


Received: (at 48579) by debbugs.gnu.org; 22 May 2021 12:37:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat May 22 08:37:44 2021
Received: from localhost ([127.0.0.1]:38483 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lkQsy-0007gU-7V
	for submit <at> debbugs.gnu.org; Sat, 22 May 2021 08:37:44 -0400
Received: from server.qxqx.de ([178.63.65.180]:60713 helo=mail.qxqx.de)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1lkQsw-0007gH-Jn
 for 48579 <at> debbugs.gnu.org; Sat, 22 May 2021 08:37:43 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=qxqx.de;
 s=mail1392553390; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:
 MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender:Reply-To:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=b+mkkd3QYxqLwAgjVgl5VUX6kOSYtPUURNzXH2ekqrQ=; b=LikW2d9lCJxNCR8MHs3NJGP08T
 pgy3PbdIBWA6S20V67X6MgXdcZen7MiZVd3w8xNFWIt6ZEkc5UyLr0rfhZ2feNTp5B1U3pBzJCslu
 eQF+rnq8/pPrczNY7bP0Ha2pmhnxzwf0vhgiwQu1Aq+9jdnhqbs/szQrdY1ih+UoIiYM=;
Subject: Re: bug#48579: 28.0.50; Spawning an emacs process using call-process
 results in inconsistent, behavior between GNU/Linux and macOS
To: Eli Zaretskii <eliz@HIDDEN>
References: <2d81bff4-21fc-ce96-f1f1-f0bbf60b233e@HIDDEN>
 <837djrklhx.fsf@HIDDEN>
From: Daniel Mendler <mail@HIDDEN>
Message-ID: <ed6f5225-f1b4-fbda-286c-17138e45d63f@HIDDEN>
Date: Sat, 22 May 2021 14:37:35 +0200
MIME-Version: 1.0
In-Reply-To: <837djrklhx.fsf@HIDDEN>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: -1.6 (-)
X-Debbugs-Envelope-To: 48579
Cc: alan@HIDDEN, 48579 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.6 (--)

On 5/22/21 2:20 PM, Eli Zaretskii wrote:
>> Cc: alan@HIDDEN, 48579 <at> debbugs.gnu.org
>> From: Daniel Mendler <mail@HIDDEN>
>> Date: Sat, 22 May 2021 13:44:27 +0200
>>
>> 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 this is what you think, then your concept of the default-directory
> is in direct contradiction with how Emacs works.  The cwd of the Emacs
> process is immaterial, and actually not even easily visible inside
> Emacs.  When a buffer visits a file, Emacs makes a point of behaving
> like that file's directory was its cwd.  For other buffers, my
> suggestion is to consider their default-directory to be indeterminate,
> and if you need it to have a specified value, you should force that by
> calling 'cd' or setting default-directory explicitly.  Anything else
> is bound to trip you some day, because it simply isn't how Emacs was
> designed to behave.

I am aware that the file visiting buffers have a different
default-directory. However the initial scratch buffer should inherit the
current working directory of the parent process. I don't see why some
"indeterminate" or "undefined" behavior is justified here.

> So when you say that Emacs should behave the same on these platforms,
> you should first ask yourself what is that "same behavior".  My answer
> is simple: you cannot predict what is the default-directory of a
> random buffer that doesn't visit a file.  In this sense, Emacs indeed
> works the same on all platforms.  Any other sense you may wish to
> assign to that is simply a basic mistake.

There is no technical roadblock preventing Emacs from determining the
current directory (at least on Unixes). The problem is that the Mac
Emacs port changes the directory according to its own standards.

Why do you call this "indeterminate", "undefined" or "random" behavior?
Are there other examples where buffers have random directories?

Daniel




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#48579; Package emacs. Full text available.

Message received at 48579 <at> debbugs.gnu.org:


Received: (at 48579) by debbugs.gnu.org; 22 May 2021 12:29:17 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat May 22 08:29:16 2021
Received: from localhost ([127.0.0.1]:38470 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lkQkm-0005IR-N0
	for submit <at> debbugs.gnu.org; Sat, 22 May 2021 08:29:16 -0400
Received: from eggs.gnu.org ([209.51.188.92]:54426)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lkQkj-0005IA-8L
 for 48579 <at> debbugs.gnu.org; Sat, 22 May 2021 08:29:15 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:58574)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lkQkd-00071K-DZ; Sat, 22 May 2021 08:29:07 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2622
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1lkQkc-0007WC-3x; Sat, 22 May 2021 08:29:07 -0400
Date: Sat, 22 May 2021 15:29:08 +0300
Message-Id: <834kevkl4b.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Daniel Mendler <mail@HIDDEN>
In-Reply-To: <9002b376-2ef7-db7d-9d7a-092cda82efe1@HIDDEN> (message
 from Daniel Mendler on Sat, 22 May 2021 14:14:53 +0200)
Subject: Re: bug#48579: 28.0.50; Spawning an emacs process using call-process
 results in inconsistent, behavior between GNU/Linux and macOS
References: <2d81bff4-21fc-ce96-f1f1-f0bbf60b233e@HIDDEN>
 <YKjzrtZkqFL8lwZp@HIDDEN>
 <9002b376-2ef7-db7d-9d7a-092cda82efe1@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 48579
Cc: alan@HIDDEN, 48579 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Daniel Mendler <mail@HIDDEN>
> Date: Sat, 22 May 2021 14:14:53 +0200
> 
> > 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, 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?

That won't help.  The initial directory in which Emacs starts can be
controlled that way, but that's not what you will see in some random
buffer's default-directory.  It is completely OK for Emacs to change
its cwd, as far as the OS is concerned, after it was started, because
that directory doesn't affect how Emacs works.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#48579; Package emacs. Full text available.

Message received at 48579 <at> debbugs.gnu.org:


Received: (at 48579) by debbugs.gnu.org; 22 May 2021 12:21:07 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat May 22 08:21:07 2021
Received: from localhost ([127.0.0.1]:38452 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lkQct-00056D-Bu
	for submit <at> debbugs.gnu.org; Sat, 22 May 2021 08:21:07 -0400
Received: from eggs.gnu.org ([209.51.188.92]:52948)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lkQcr-00055Q-94
 for 48579 <at> debbugs.gnu.org; Sat, 22 May 2021 08:21:06 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:58470)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lkQcl-0004Dj-Ep; Sat, 22 May 2021 08:20:59 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2117
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1lkQcl-0001KZ-2r; Sat, 22 May 2021 08:20:59 -0400
Date: Sat, 22 May 2021 15:20:58 +0300
Message-Id: <837djrklhx.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Daniel Mendler <mail@HIDDEN>
In-Reply-To: <2d81bff4-21fc-ce96-f1f1-f0bbf60b233e@HIDDEN> (message
 from Daniel Mendler on Sat, 22 May 2021 13:44:27 +0200)
Subject: Re: bug#48579: 28.0.50; Spawning an emacs process using call-process
 results in inconsistent, behavior between GNU/Linux and macOS
References: <2d81bff4-21fc-ce96-f1f1-f0bbf60b233e@HIDDEN>
X-Spam-Score: -1.6 (-)
X-Debbugs-Envelope-To: 48579
Cc: alan@HIDDEN, 48579 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.6 (--)

> Cc: alan@HIDDEN, 48579 <at> debbugs.gnu.org
> From: Daniel Mendler <mail@HIDDEN>
> Date: Sat, 22 May 2021 13:44:27 +0200
> 
> 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 this is what you think, then your concept of the default-directory
is in direct contradiction with how Emacs works.  The cwd of the Emacs
process is immaterial, and actually not even easily visible inside
Emacs.  When a buffer visits a file, Emacs makes a point of behaving
like that file's directory was its cwd.  For other buffers, my
suggestion is to consider their default-directory to be indeterminate,
and if you need it to have a specified value, you should force that by
calling 'cd' or setting default-directory explicitly.  Anything else
is bound to trip you some day, because it simply isn't how Emacs was
designed to behave.

So when you say that Emacs should behave the same on these platforms,
you should first ask yourself what is that "same behavior".  My answer
is simple: you cannot predict what is the default-directory of a
random buffer that doesn't visit a file.  In this sense, Emacs indeed
works the same on all platforms.  Any other sense you may wish to
assign to that is simply a basic mistake.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#48579; Package emacs. Full text available.

Message received at 48579 <at> debbugs.gnu.org:


Received: (at 48579) by debbugs.gnu.org; 22 May 2021 12:15:04 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat May 22 08:15:04 2021
Received: from localhost ([127.0.0.1]:38442 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lkQX2-0004ws-Dy
	for submit <at> debbugs.gnu.org; Sat, 22 May 2021 08:15:04 -0400
Received: from server.qxqx.de ([178.63.65.180]:60921 helo=mail.qxqx.de)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1lkQWz-0004w2-5O
 for 48579 <at> debbugs.gnu.org; Sat, 22 May 2021 08:15:02 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=qxqx.de;
 s=mail1392553390; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:
 MIME-Version:Date:Message-ID:From:References:To:Subject:Sender:Reply-To:Cc:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=OPW//nDUYl2azZNFUvY3pi73mCIXQt1tgDDdM74PsKI=; b=DN9wQS3tCeyP17dSZPrYxMUVFE
 3w3/veGjWKJ5fpWyCCJ+FPKOXlkZzSX+UpifoRxwM7hvNFXo6N7+wwwV8rCIX/7gWYpP6Isjd1xSA
 MN+Mb6hy6divxtG2lZwxB0R9jn+7f0CAAkS3QGWori2nGpIFg6FcKgbIl6CH5B4phGlE=;
Subject: Re: bug#48579: 28.0.50; Spawning an emacs process using call-process
 results in inconsistent, behavior between GNU/Linux and macOS
To: Alan Third <alan@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>,
 48579 <at> debbugs.gnu.org
References: <2d81bff4-21fc-ce96-f1f1-f0bbf60b233e@HIDDEN>
 <YKjzrtZkqFL8lwZp@HIDDEN>
From: Daniel Mendler <mail@HIDDEN>
Message-ID: <9002b376-2ef7-db7d-9d7a-092cda82efe1@HIDDEN>
Date: Sat, 22 May 2021 14:14:53 +0200
MIME-Version: 1.0
In-Reply-To: <YKjzrtZkqFL8lwZp@HIDDEN>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 48579
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

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, 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?

Daniel




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#48579; Package emacs. Full text available.

Message received at 48579 <at> debbugs.gnu.org:


Received: (at 48579) by debbugs.gnu.org; 22 May 2021 12:06:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat May 22 08:06:19 2021
Received: from localhost ([127.0.0.1]:38432 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lkQOZ-0004jn-AG
	for submit <at> debbugs.gnu.org; Sat, 22 May 2021 08:06:19 -0400
Received: from outbound.soverin.net ([116.202.65.218]:40769)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <alan@HIDDEN>) id 1lkQOW-0004jZ-To
 for 48579 <at> debbugs.gnu.org; Sat, 22 May 2021 08:06:17 -0400
Received: from smtp.soverin.net (unknown [10.10.3.24])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
 (No client certificate requested)
 by outbound.soverin.net (Postfix) with ESMTPS id C1F786008B;
 Sat, 22 May 2021 12:06:10 +0000 (UTC)
Received: from smtp.soverin.net (smtp.soverin.net [159.69.232.138]) by
 soverin.net
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=idiocy.org; s=soverin;
 t=1621685169; bh=dcw0CTuIXcOiyQEq8PY1e+P7i4+guW1BX3fPP9kU+vA=;
 h=Date:From:To:Cc:Subject:References:In-Reply-To:From;
 b=ki6b/XQ9JVlBVNfAJe/DchY3h5f8LhbrEqvqT3G1Cc1flwnz7SXROLNE9v1SdZMjJ
 ++C97ynSPD1GPKgRjD1UgOeFAgC83KJf6wKEU8dhfhA7YoW+02RDlt/vaLMbNAmLIw
 VXJJn2GlTt0R6esj4L6pPn6BKahJvQfiEkECxIJruiM7YcwB4okMnp+HHLZOYVGzzx
 8NwDFvxwRU9fR6V6AKIXKmjsa7t0T+uv1fiZUdp6MnR3VJodCtBZiFZ3WaYYiej/Eb
 rZEFLLL+SBQJe/NoZHIk16FJyM5ybu4E9Y44XIbIsWiYBk5dnnsHQqXuGAFY9cKc1t
 xX3XBsoG2TGiA==
Received: from alan by faroe.holly.idiocy.org with local (Exim 4.94.2)
 (envelope-from <alan@HIDDEN>)
 id 1lkQOM-0007WJ-5Q; Sat, 22 May 2021 13:06:06 +0100
Date: Sat, 22 May 2021 13:06:06 +0100
From: Alan Third <alan@HIDDEN>
To: Daniel Mendler <mail@HIDDEN>
Subject: Re: bug#48579: 28.0.50; Spawning an emacs process using call-process
 results in inconsistent, behavior between GNU/Linux and macOS
Message-ID: <YKjzrtZkqFL8lwZp@HIDDEN>
Mail-Followup-To: Alan Third <alan@HIDDEN>,
 Daniel Mendler <mail@HIDDEN>,
 Eli Zaretskii <eliz@HIDDEN>, 48579 <at> debbugs.gnu.org
References: <2d81bff4-21fc-ce96-f1f1-f0bbf60b233e@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <2d81bff4-21fc-ce96-f1f1-f0bbf60b233e@HIDDEN>
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 48579
Cc: Eli Zaretskii <eliz@HIDDEN>, 48579 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

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.
-- 
Alan Third




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#48579; Package emacs. Full text available.

Message received at 48579 <at> debbugs.gnu.org:


Received: (at 48579) by debbugs.gnu.org; 22 May 2021 11:44:37 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat May 22 07:44:37 2021
Received: from localhost ([127.0.0.1]:38402 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lkQ3Z-0004C2-23
	for submit <at> debbugs.gnu.org; Sat, 22 May 2021 07:44:37 -0400
Received: from server.qxqx.de ([178.63.65.180]:39945 helo=mail.qxqx.de)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1lkQ3W-0004Bm-R1
 for 48579 <at> debbugs.gnu.org; Sat, 22 May 2021 07:44:35 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=qxqx.de;
 s=mail1392553390; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Date:
 Message-ID:Subject:From:Cc:To:Sender:Reply-To:Content-ID:Content-Description:
 Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:
 In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:
 List-Post:List-Owner:List-Archive;
 bh=hDQBwnnyt5H17hza3mnRVhghCpXeOncUcenrgHhOZ/w=; b=mHDVrBwdRgeBKYFqYQ/YsLk9Co
 TePtpo8SIgYhzPal2t+npWpXIfRIP6B4Y+4LQfdU/knZMJvT4MseRmS4irDoJ0EN9FAFqTrgYjKVu
 s4jed1xeldcWT1jzJJNCeYJafvuATFZ9eHdSwnSkcJb1g6vT7B/KJYsnJnMFlUnEZvNw=;
To: Eli Zaretskii <eliz@HIDDEN>
From: Daniel Mendler <mail@HIDDEN>
Subject: Re: bug#48579: 28.0.50; Spawning an emacs process using call-process
 results in inconsistent, behavior between GNU/Linux and macOS
Message-ID: <2d81bff4-21fc-ce96-f1f1-f0bbf60b233e@HIDDEN>
Date: Sat, 22 May 2021 13:44:27 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 48579
Cc: alan@HIDDEN, 48579 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Bottom line: I don't see any Emacs bug here.

Of course there is an Emacs bug here.

I am using `call-process` to start Emacs. On Mac the home directory is
taken on other Unixes the current directory of the parent process is taken.

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.

Daniel




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#48579; Package emacs. Full text available.

Message received at 48579 <at> debbugs.gnu.org:


Received: (at 48579) by debbugs.gnu.org; 22 May 2021 10:39:14 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat May 22 06:39:14 2021
Received: from localhost ([127.0.0.1]:38361 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lkP2I-0000S1-80
	for submit <at> debbugs.gnu.org; Sat, 22 May 2021 06:39:14 -0400
Received: from eggs.gnu.org ([209.51.188.92]:36168)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lkP2E-0000Rf-1t
 for 48579 <at> debbugs.gnu.org; Sat, 22 May 2021 06:39:13 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:56942)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lkP27-0001i0-64; Sat, 22 May 2021 06:39:03 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3769
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1lkP26-0003PG-OQ; Sat, 22 May 2021 06:39:03 -0400
Date: Sat, 22 May 2021 13:39:03 +0300
Message-Id: <83a6onkq7s.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Alan Third <alan@HIDDEN>
In-Reply-To: <YKjcSA/E3hO+i8Z7@HIDDEN> (message from Alan Third on Sat, 22
 May 2021 11:26:16 +0100)
Subject: Re: bug#48579: 28.0.50;
 Spawning an emacs process using call-process results in inconsistent
 behavior between GNU/Linux and macOS
References: <CAOotCtPMnHpVmetVs+EncvtqCsVuaSwNkuEsvMKAqBkhGJZygw@HIDDEN>
 <YKjcSA/E3hO+i8Z7@HIDDEN>
X-Spam-Score: -1.6 (-)
X-Debbugs-Envelope-To: 48579
Cc: rajkrishnan1996@HIDDEN, 48579 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.6 (--)

> Date: Sat, 22 May 2021 11:26:16 +0100
> From: Alan Third <alan@HIDDEN>
> Cc: 48579 <at> debbugs.gnu.org
> 
> > 5. Behavior on GNU/Linux: The directory matches the value shown in (2)
> >    Behavior on macOS: The default directory has changed to the user's
> >    home directory
> > 
> > The behavior was spotted when we noticed inconsistent behavior in
> > [[https://github.com/minad/affe][affe.el]], which was subsequently
> > reproduced using =emacs -Q=
> 
> The NS port checks if it's connected to a TTY when it starts, and if
> not assumes it's being run from finder and so sets the starting
> directory to something useful ($HOME), instead of / or whatever it
> defaults to.

I think any Lisp program that assumes something about the directory of
the *scratch* buffer based on where Emacs was invoked is buggy.  E.g.,
on MS-Windows one can specify a starting directory for Emacs via the
properties of the Emacs desktop icon, and Lisp programs have no way of
knowing where that is.

Lisp programs that want rely on the value of the default directory
should explicitly call 'cd' to change to that directory (passing it
via command-line arguments if necessary, as it probably is in the case
in point).

Bottom line: I don't see any Emacs bug here.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#48579; Package emacs. Full text available.

Message received at 48579 <at> debbugs.gnu.org:


Received: (at 48579) by debbugs.gnu.org; 22 May 2021 10:26:30 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat May 22 06:26:30 2021
Received: from localhost ([127.0.0.1]:38357 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lkOpy-00006r-0a
	for submit <at> debbugs.gnu.org; Sat, 22 May 2021 06:26:30 -0400
Received: from outbound.soverin.net ([116.202.65.218]:43909)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <alan@HIDDEN>) id 1lkOpt-00006Y-IH
 for 48579 <at> debbugs.gnu.org; Sat, 22 May 2021 06:26:27 -0400
Received: from smtp.soverin.net (unknown [10.10.3.28])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
 (No client certificate requested)
 by outbound.soverin.net (Postfix) with ESMTPS id 3CB7B60109
 for <48579 <at> debbugs.gnu.org>; Sat, 22 May 2021 10:26:19 +0000 (UTC)
Received: from smtp.soverin.net (smtp.soverin.net [159.69.232.142]) by
 soverin.net
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=idiocy.org; s=soverin;
 t=1621679178; bh=3NoctDQ5tWw7Yz/6WHY6xXiy6Xhoe57wEppjCzDhBYs=;
 h=Date:From:To:Cc:Subject:References:In-Reply-To:From;
 b=Z+YyGQoHiHRpwZMnhiMYXu99cWc+F4w2ZljANlNPLSQuforNQ5siR0GgH01b6ogUR
 djFdw6/5+bHfxp0OmkDqhCeGUfGB3qb8IpP4QFHB3WbVru3AT0BaE/94Qy594BpzuI
 WaPDK9CBs2Y/C5LLjaY7MhuVVDlcTq9zxc74OT58tOTcK4lkEcC6blhstx7UGq2daU
 vKzHCvCp2e/fI3B+qYWBVou5RjPmP+SgrYHKLdkFyuSrrSqraKMBpQNeafDGDCkfJh
 44BXFlIimnmgcwzwmc30DABgiNgChAZjbx714iITC2ZdyEOi4sWPSXvIY6FJGCphdF
 OSe5iklnl4Kzw==
Received: from alan by faroe.holly.idiocy.org with local (Exim 4.94.2)
 (envelope-from <alan@HIDDEN>)
 id 1lkOpk-0007KY-3L; Sat, 22 May 2021 11:26:16 +0100
Date: Sat, 22 May 2021 11:26:16 +0100
From: Alan Third <alan@HIDDEN>
To: Raj Krishnan <rajkrishnan1996@HIDDEN>
Subject: Re: bug#48579: 28.0.50; Spawning an emacs process using call-process
 results in inconsistent behavior between GNU/Linux and macOS
Message-ID: <YKjcSA/E3hO+i8Z7@HIDDEN>
Mail-Followup-To: Alan Third <alan@HIDDEN>,
 Raj Krishnan <rajkrishnan1996@HIDDEN>, 48579 <at> debbugs.gnu.org
References: <CAOotCtPMnHpVmetVs+EncvtqCsVuaSwNkuEsvMKAqBkhGJZygw@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <CAOotCtPMnHpVmetVs+EncvtqCsVuaSwNkuEsvMKAqBkhGJZygw@HIDDEN>
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 48579
Cc: 48579 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Sat, May 22, 2021 at 11:00:43AM +0530, Raj Krishnan wrote:
> Steps for reproduction:
> 1. Run =emacs -Q= in some directory outside the user's home directory
> 2. Check the value of the variable =default-directory=, and verify that
>    it matches the directory you started emacs in
> 3. Create an emacs child process using:
> 
> #+begin_src emacs_lisp
>   (call-process
>     (file-truename (expand-file-name invocation-name invocation-directory))
>     nil nil nil "-Q")
> #+end_src
> 
> 4. In the newly created frame, check the value of the default directory
> 
> 5. Behavior on GNU/Linux: The directory matches the value shown in (2)
>    Behavior on macOS: The default directory has changed to the user's
>    home directory
> 
> The behavior was spotted when we noticed inconsistent behavior in
> [[https://github.com/minad/affe][affe.el]], which was subsequently
> reproduced using =emacs -Q=

The NS port checks if it's connected to a TTY when it starts, and if
not assumes it's being run from finder and so sets the starting
directory to something useful ($HOME), instead of / or whatever it
defaults to.

-- 
Alan Third




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#48579; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 22 May 2021 07:35:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat May 22 03:35:44 2021
Received: from localhost ([127.0.0.1]:38253 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lkMAT-0004Rg-G6
	for submit <at> debbugs.gnu.org; Sat, 22 May 2021 03:35:44 -0400
Received: from lists.gnu.org ([209.51.188.17]:43930)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rajkrishnan1996@HIDDEN>) id 1lkKEE-00017I-8p
 for submit <at> debbugs.gnu.org; Sat, 22 May 2021 01:31:14 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:42420)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <rajkrishnan1996@HIDDEN>)
 id 1lkKEE-00070o-1d
 for bug-gnu-emacs@HIDDEN; Sat, 22 May 2021 01:31:14 -0400
Received: from mail-ot1-x334.google.com ([2607:f8b0:4864:20::334]:36427)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <rajkrishnan1996@HIDDEN>)
 id 1lkKEB-0004IL-Bt
 for bug-gnu-emacs@HIDDEN; Sat, 22 May 2021 01:31:13 -0400
Received: by mail-ot1-x334.google.com with SMTP id
 n32-20020a9d1ea30000b02902a53d6ad4bdso20023485otn.3
 for <bug-gnu-emacs@HIDDEN>; Fri, 21 May 2021 22:31:10 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:from:date:message-id:subject:to;
 bh=UAMjkXumv3YHQ5/u8gUGDciXWS5lQc1lk84pTi0Ox6s=;
 b=MhdYyR8mDAs56WsKkoDqTxQ4aDTtzto/7LYjCL1JsIkal03sQLTrUsl7cZvCQz/iNs
 Rr+U47jiUdVLlALAOlx4RCgJ7Rqc1+BJM/dSqQ3Ou75B0YiFxhbIQOW06wi8d/W8E+eS
 HZRT1UzIhMJBhrSgLmquxyy/bQFyvIn1cMb2DTtvE2YJceriarGzpA9LJtUAaPXE5VeO
 q6/zSLlMSNeJ8AIAQyr2JcBsTwpbGuGcOQouaZbrhtDbdTLQ1USMBDk3/TwBHsWzEW/q
 CMPZ39tT71xWHhewRSf5MmNzw/Ff8b9JBM0bzLGw1zi8zZV4xKzjG0lv/K8/bLUVgMWl
 mC2Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
 bh=UAMjkXumv3YHQ5/u8gUGDciXWS5lQc1lk84pTi0Ox6s=;
 b=e8hBWoJB4/DLHf5bYQkWEvKwogoXsLb4l2txNURIFidlWLGH6vj77mlIelE+4nqVca
 5H7UnIb95IDpA65k7k4IFML5tAGSgI/p7ltCQkBXUMAzYrj0fgT4EDH1n5GNVmZXz7tg
 4MPiaZLcpIwqC8MIhgeSu1LWJ3wfHnzpehZTdE/zf5WURGD3F0Ylu5OoYH7JSklzpPEj
 JVtBFu8w3fC5wmWChLPVfcnv32CMp2Qy2su/WvCvOR3/wXTORhpPYukZ22V4YRGgReSu
 9+JIlAcvozmiFqZScetvOxIOo6HT2ogRw+DMpbAH8KEdVHb0GYkk9Ht7fNu9lGxQT9In
 CD5g==
X-Gm-Message-State: AOAM530PpDzmeTcEL1VWVm84i/GHBXWZ7yo7YaUUzJxwcWv+CBQn3TQ9
 q93YsFP2dRQ/gdtqvvIX9g8P+Fj+JL8wVQdX/7GVgeu/doXv4A==
X-Google-Smtp-Source: ABdhPJxGO/CaHeXvBtFUEa959Q/ikim4zzp2Om05r28cdNU8wSI6kj16u8JvbPCT7vuX3iMbXJUDf22mTjk4NwHZTYY=
X-Received: by 2002:a05:6830:1155:: with SMTP id
 x21mr10835920otq.303.1621661469184; 
 Fri, 21 May 2021 22:31:09 -0700 (PDT)
MIME-Version: 1.0
From: Raj Krishnan <rajkrishnan1996@HIDDEN>
Date: Sat, 22 May 2021 11:00:43 +0530
Message-ID: <CAOotCtPMnHpVmetVs+EncvtqCsVuaSwNkuEsvMKAqBkhGJZygw@HIDDEN>
Subject: 28.0.50; Spawning an emacs process using call-process results in
 inconsistent behavior between GNU/Linux and macOS
To: bug-gnu-emacs@HIDDEN
Content-Type: multipart/alternative; boundary="000000000000d116ab05c2e47b26"
Received-SPF: pass client-ip=2607:f8b0:4864:20::334;
 envelope-from=rajkrishnan1996@HIDDEN; helo=mail-ot1-x334.google.com
X-Spam_score_int: -17
X-Spam_score: -1.8
X-Spam_bar: -
X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.1 (-)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Sat, 22 May 2021 03:35:29 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--000000000000d116ab05c2e47b26
Content-Type: text/plain; charset="UTF-8"

Steps for reproduction:
1. Run =emacs -Q= in some directory outside the user's home directory
2. Check the value of the variable =default-directory=, and verify that
   it matches the directory you started emacs in
3. Create an emacs child process using:

#+begin_src emacs_lisp
  (call-process
    (file-truename (expand-file-name invocation-name invocation-directory))
    nil nil nil "-Q")
#+end_src

4. In the newly created frame, check the value of the default directory

5. Behavior on GNU/Linux: The directory matches the value shown in (2)
   Behavior on macOS: The default directory has changed to the user's
   home directory

The behavior was spotted when we noticed inconsistent behavior in
[[https://github.com/minad/affe][affe.el]], which was subsequently
reproduced using =emacs -Q=




In GNU Emacs 28.0.50 (build 2, aarch64-apple-darwin20.4.0, NS
appkit-2022.44 Version 11.3.1 (Build 20E241))
 of 2021-05-16 built on localhost
Repository revision: 1b8f013d179e8866819fe53b4708b57e753a08fc
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2022
System Description:  macOS 11.3.1

Configured using:
 'configure --with-ns --with-modules --with-gnutls CFLAGS=-O3'

Configured features:
ACL GLIB GNUTLS JSON LCMS2 LIBXML2 MODULES NOTIFY KQUEUE NS PDUMPER PNG
RSVG THREADS TOOLKIT_SCROLL_BARS XIM ZLIB

Important settings:
  value of $LC_CTYPE: UTF-8
  value of $LANG: en_IN.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg epg-config gnus-util rmail
rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json map text-property-search time-date
subr-x seq byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs
cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
iso-transl tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/ns-win ns-win ucs-normalize mule-util
term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button
loaddefs faces cus-face macroexp files window text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads kqueue cocoa ns lcms2
multi-tty make-network-process emacs)

Memory information:
((conses 16 50394 13010)
 (symbols 48 6513 1)
 (strings 32 18129 1897)
 (string-bytes 1 601636)
 (vectors 16 12488)
 (vector-slots 8 175753 14592)
 (floats 8 21 50)
 (intervals 56 206 0)
 (buffers 992 11))

--000000000000d116ab05c2e47b26
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Steps for reproduction:<br>1. Run =3Demacs -Q=3D in some d=
irectory outside the user&#39;s home directory<br>2. Check the value of the=
 variable =3Ddefault-directory=3D, and verify that<br>=C2=A0 =C2=A0it match=
es the directory you started emacs in<br>3. Create an emacs child process u=
sing:<br><br>#+begin_src emacs_lisp<br>=C2=A0 (call-process<br>=C2=A0 =C2=
=A0 (file-truename (expand-file-name invocation-name invocation-directory))=
<br>=C2=A0 =C2=A0 nil nil nil &quot;-Q&quot;)<br>#+end_src<br><br>4. In the=
 newly created frame, check the value of the default directory<br><br>5. Be=
havior on GNU/Linux: The directory matches the value shown in (2)<br>=C2=A0=
 =C2=A0Behavior on macOS: The default directory has changed to the user&#39=
;s<br>=C2=A0 =C2=A0home directory<br><br>The behavior was spotted when we n=
oticed inconsistent behavior in<br>[[<a href=3D"https://github.com/minad/af=
fe][affe.el]">https://github.com/minad/affe][affe.el]</a>], which was subse=
quently<br>reproduced using =3Demacs -Q=3D<br><br><br><br><br>In GNU Emacs =
28.0.50 (build 2, aarch64-apple-darwin20.4.0, NS appkit-2022.44 Version 11.=
3.1 (Build 20E241))<br>=C2=A0of 2021-05-16 built on localhost<br>Repository=
 revision: 1b8f013d179e8866819fe53b4708b57e753a08fc<br>Repository branch: m=
aster<br>Windowing system distributor &#39;Apple&#39;, version 10.3.2022<br=
>System Description: =C2=A0macOS 11.3.1<br><br>Configured using:<br>=C2=A0&=
#39;configure --with-ns --with-modules --with-gnutls CFLAGS=3D-O3&#39;<br><=
br>Configured features:<br>ACL GLIB GNUTLS JSON LCMS2 LIBXML2 MODULES NOTIF=
Y KQUEUE NS PDUMPER PNG<br>RSVG THREADS TOOLKIT_SCROLL_BARS XIM ZLIB<br><br=
>Important settings:<br>=C2=A0 value of $LC_CTYPE: UTF-8<br>=C2=A0 value of=
 $LANG: en_IN.UTF-8<br>=C2=A0 locale-coding-system: utf-8-unix<br><br>Major=
 mode: Lisp Interaction<br><br>Minor modes in effect:<br>=C2=A0 tooltip-mod=
e: t<br>=C2=A0 global-eldoc-mode: t<br>=C2=A0 eldoc-mode: t<br>=C2=A0 elect=
ric-indent-mode: t<br>=C2=A0 mouse-wheel-mode: t<br>=C2=A0 tool-bar-mode: t=
<br>=C2=A0 menu-bar-mode: t<br>=C2=A0 file-name-shadow-mode: t<br>=C2=A0 gl=
obal-font-lock-mode: t<br>=C2=A0 font-lock-mode: t<br>=C2=A0 blink-cursor-m=
ode: t<br>=C2=A0 auto-composition-mode: t<br>=C2=A0 auto-encryption-mode: t=
<br>=C2=A0 auto-compression-mode: t<br>=C2=A0 line-number-mode: t<br>=C2=A0=
 transient-mark-mode: t<br><br>Load-path shadows:<br>None found.<br><br>Fea=
tures:<br>(shadow sort mail-extr emacsbug message rmc puny dired dired-load=
defs<br>rfc822 mml mml-sec epa derived epg epg-config gnus-util rmail<br>rm=
ail-loaddefs auth-source cl-seq eieio eieio-core cl-macs<br>eieio-loaddefs =
password-cache json map text-property-search time-date<br>subr-x seq byte-o=
pt gv bytecomp byte-compile cconv mm-decode mm-bodies<br>mm-encode mail-par=
se rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs<br>cl-lib sendmail r=
fc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils<br>iso-transl toolt=
ip eldoc electric uniquify ediff-hook vc-hooks<br>lisp-float-type mwheel te=
rm/ns-win ns-win ucs-normalize mule-util<br>term/common-win tool-bar dnd fo=
ntset image regexp-opt fringe<br>tabulated-list replace newcomment text-mod=
e elisp-mode lisp-mode<br>prog-mode register page tab-bar menu-bar rfn-esha=
dow isearch easymenu<br>timer select scroll-bar mouse jit-lock font-lock sy=
ntax font-core<br>term/tty-colors frame minibuffer cl-generic cham georgian=
 utf-8-lang<br>misc-lang vietnamese tibetan thai tai-viet lao korean japane=
se eucjp-ms<br>cp51932 hebrew greek romanian slovak czech european ethiopic=
 indian<br>cyrillic chinese composite charscript charprop case-table epa-ho=
ok<br>jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button<=
br>loaddefs faces cus-face macroexp files window text-properties overlay<br=
>sha1 md5 base64 format env code-pages mule custom widget<br>hashtable-prin=
t-readable backquote threads kqueue cocoa ns lcms2<br>multi-tty make-networ=
k-process emacs)<br><br>Memory information:<br>((conses 16 50394 13010)<br>=
=C2=A0(symbols 48 6513 1)<br>=C2=A0(strings 32 18129 1897)<br>=C2=A0(string=
-bytes 1 601636)<br>=C2=A0(vectors 16 12488)<br>=C2=A0(vector-slots 8 17575=
3 14592)<br>=C2=A0(floats 8 21 50)<br>=C2=A0(intervals 56 206 0)<br>=C2=A0(=
buffers 992 11))<br></div>

--000000000000d116ab05c2e47b26--




Acknowledgement sent to Raj Krishnan <rajkrishnan1996@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#48579; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sun, 23 May 2021 10:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.