From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#65048: 29.1; cli argument "-x" fails with "unknown option" error on PGTK Emacs Date: Fri, 04 Aug 2023 09:20:54 +0300 Message-ID: <83fs4zwcop.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5269"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 65048@debbugs.gnu.org To: John t Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Aug 04 08:21:35 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qRoBp-00011i-Cj for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 04 Aug 2023 08:21:33 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qRoBZ-0007tq-6V; Fri, 04 Aug 2023 02:21:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qRoBK-0007ft-67 for bug-gnu-emacs@gnu.org; Fri, 04 Aug 2023 02:21:02 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qRoBJ-0005U4-Or for bug-gnu-emacs@gnu.org; Fri, 04 Aug 2023 02:21:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qRoBJ-0007MT-KU for bug-gnu-emacs@gnu.org; Fri, 04 Aug 2023 02:21:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 04 Aug 2023 06:21:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65048 X-GNU-PR-Package: emacs Original-Received: via spool by 65048-submit@debbugs.gnu.org id=B65048.169113005228274 (code B ref 65048); Fri, 04 Aug 2023 06:21:01 +0000 Original-Received: (at 65048) by debbugs.gnu.org; 4 Aug 2023 06:20:52 +0000 Original-Received: from localhost ([127.0.0.1]:53282 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qRoBA-0007Lv-CM for submit@debbugs.gnu.org; Fri, 04 Aug 2023 02:20:52 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54398) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qRoB7-0007Lh-TA for 65048@debbugs.gnu.org; Fri, 04 Aug 2023 02:20:50 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qRoB2-0005RG-LB; Fri, 04 Aug 2023 02:20:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=QL2cz6cPJlD+VgL1Y3WNkh+znBuSzrmdPdvNcdhrptY=; b=E1cuLAd+TK6v BA1cGLCREipwbynj7plOW8VLnUYIA601jetj0BYxHoWPIdlWM5VvdGjqs4a8AnvBb7bEm/lNpx9FK F3a+GT2PaceqcmrK3auz5xcndFORI/qd2ydzRcQN3hD7K06Joa9iMIbXphCQ0Q1hQVTDdubTY0DBH uUJOY6nfsetaCno7mAW7/oH18PCIKb/JnyVRikzWIbFjOQJ6dHxV2RjJh5Y9btR4vLGQkCNCmNBZ4 CASsZNxdp9hKwfJKvl6bIXO5/HKTZraocnCjaHxzPDJV/FHiyTOCYCBbiKC6J+u0DfQtpxQMnm30c cT80TBwI/+Fma8Ae2zs65A==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qRoB1-00080B-Hi; Fri, 04 Aug 2023 02:20:43 -0400 In-Reply-To: (message from John t on Thu, 3 Aug 2023 22:47:19 -0400) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:266645 Archived-At: > From: John t > Date: Thu, 3 Aug 2023 22:47:19 -0400 > > Scripts starting with "#!/usr/bin/emacs -x" do not function with PGTK Emacs. > > Instead of evaluating the file contents, Emacs creates a new instance > and opens a frame, echos a warning about "-x" being an unknown option in > the minibuffer. This seems to suggest that the "-x" option is not being recognized at all. > > The statement that parses this specific parameter seems to be inside > of a conditionally compiled block of code that toggles based on the > macro HAVE_X_WINDOWS (#ifdef HAVE_X_WINDOWS). > > My current build of Emacs uses the PGTK, and non-PGTK builds appear to > function correctly when used with the "-x" option. > > This option doesn't seem to be related to x11 in any way as far as I can > tell, so I have moved it to the location where the "--script" option is > parsed, and then decrement skip_args by 2 instead of 1 which is also what > "--script" does. > > These changes cause the "-x" option to function correctly, but I am not > experienced in C or with the C parts of Emacs, so this may not be the > correct solution! Thanks. You are right: the -x switch should not be X-specific. Please try the patch below instead (which removes some duplicate code, but is in general the same idea as in your suggested patch). Please try this both in the PGTK and in non-PGTK builds, as I have only limited access to such configurations. diff --git a/src/emacs.c b/src/emacs.c index e63b092..37c017d 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -2007,15 +2007,16 @@ main (int argc, char **argv) } #endif /* HAVE_NS */ -#ifdef HAVE_X_WINDOWS /* Stupid kludge to catch command-line display spec. We can't handle this argument entirely in window system dependent code because we don't even know which window system dependent code to run until we've recognized this argument. */ { - char *displayname = 0; int count_before = skip_args; +#ifdef HAVE_X_WINDOWS + char *displayname = 0; + /* Skip any number of -d options, but only use the last one. */ while (!only_version) { @@ -2045,12 +2046,15 @@ main (int argc, char **argv) } argv[count_before + 1] = (char *) "-d"; } +#endif /* !HAVE_X_WINDOWS */ if (! no_site_lisp) { - if (argmatch (argv, argc, "-Q", "--quick", 3, NULL, &skip_args) + + if (argmatch (argv, argc, "-Q", "--quick", 3, NULL, &skip_args) || argmatch (argv, argc, "-quick", 0, 2, NULL, &skip_args)) - no_site_lisp = 1; + no_site_lisp = 1; + } if (argmatch (argv, argc, "-x", 0, 1, &junk, &skip_args)) @@ -2066,18 +2070,6 @@ main (int argc, char **argv) /* Don't actually discard this arg. */ skip_args = count_before; } -#else /* !HAVE_X_WINDOWS */ - if (! no_site_lisp) - { - int count_before = skip_args; - - if (argmatch (argv, argc, "-Q", "--quick", 3, NULL, &skip_args) - || argmatch (argv, argc, "-quick", 0, 2, NULL, &skip_args)) - no_site_lisp = 1; - - skip_args = count_before; - } -#endif /* argmatch must not be used after here, except when building temacs