From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jim Porter Newsgroups: gmane.emacs.bugs Subject: bug#55838: 29.0.50; [PATCH] Eshell string-split subscript indexing splits too much Date: Wed, 8 Jun 2022 16:06:45 -0700 Message-ID: References: <83edzz5l70.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35862"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 55838@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jun 09 01:07:13 2022 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 1nz4lc-0009CA-8h for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 09 Jun 2022 01:07:12 +0200 Original-Received: from localhost ([::1]:47328 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nz4la-0002Kw-Qm for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 08 Jun 2022 19:07:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44940) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nz4lS-0002Ko-Pb for bug-gnu-emacs@gnu.org; Wed, 08 Jun 2022 19:07:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50638) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nz4lS-0004f8-HU for bug-gnu-emacs@gnu.org; Wed, 08 Jun 2022 19:07:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nz4lS-0004UD-C6 for bug-gnu-emacs@gnu.org; Wed, 08 Jun 2022 19:07:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jim Porter Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 08 Jun 2022 23:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55838 X-GNU-PR-Package: emacs Original-Received: via spool by 55838-submit@debbugs.gnu.org id=B55838.165472961817235 (code B ref 55838); Wed, 08 Jun 2022 23:07:02 +0000 Original-Received: (at 55838) by debbugs.gnu.org; 8 Jun 2022 23:06:58 +0000 Original-Received: from localhost ([127.0.0.1]:44535 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nz4lN-0004Tv-TM for submit@debbugs.gnu.org; Wed, 08 Jun 2022 19:06:58 -0400 Original-Received: from mail-pj1-f41.google.com ([209.85.216.41]:42931) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nz4lJ-0004TZ-4p for 55838@debbugs.gnu.org; Wed, 08 Jun 2022 19:06:57 -0400 Original-Received: by mail-pj1-f41.google.com with SMTP id d12-20020a17090abf8c00b001e2eb431ce4so19647129pjs.1 for <55838@debbugs.gnu.org>; Wed, 08 Jun 2022 16:06:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=J0PU6BhjLKsVfk/fgbme+LV+IlMNFGOfJq07QBfnSJs=; b=OObQ4qhSnZ0cY4Twu8RaaCeNbWYuamMs5oxUOi2pCwPdL0tiAEhu2/HA4FGUrcfV/6 yu2ag5DBVl1uH1IYDpYAhWVbEP4AF4vq5rlbYrRpk/3/VLE/W7PbCQRTUekmnZncFvib AR5AanDgCCIOll4HD7Ax05uwQvztNMlQnjbMbJujgMUZk+xvdiccS532LWVl8fWVV/LM X4Ro/HOSvBhRKLfxTYEQj2IA2DezLW9TT7wGIJHrqcqkhp3BwS1rRTlBL719uDALNM1H ubRQrMXSh2ExJ3mPz7D2mCztOFQewhMECsKfbOJdC6NbhOATO+aHYz1Iw3cPjs2UN8qd +44Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=J0PU6BhjLKsVfk/fgbme+LV+IlMNFGOfJq07QBfnSJs=; b=dhTi81wqrljpfwustkJW3LPPbKneYYDJyGYbVUdSgZ9pZFUAZCLVlI9RdF5Z11Uhj+ wRnzESJ9p2FIfrohNQq2RfqFOoAMUAKR3K7jerxhuatTkKvaqLpyhrAu5u+PrhCkR5MK 76tqj9MaM+Z6s2e15JsCq64mY45vz0djSFnnan9MySGG7syVYRQ7DaSUMhlz2UST/U27 fZRjwr7Oh876SD3sH/fp/G3sQrzQ7r+OD6cgIguYfXF4W49jKI9iiL2p5yOBjpgV5fVs Wo9/64lqy1LuiXsmsF0LUjIO6g/roEywB+VvQMtTy7V2Ayso4A5Zg2/HPLd/8cTngF6v kfrw== X-Gm-Message-State: AOAM530X+aaf8NeZT+Ne2Uwbs0rsbrdArzgydQXQi1XvCrNPrlKW2R8q DPt1PZ8eeQg/N8kY1bs5PlweMwpuBwE= X-Google-Smtp-Source: ABdhPJx5mAmo93TmrJHi1L9vON2vONXAwZ27kfDAluNMTXwJbUNwu+HMWCklt17rrcgyQzWYL7F+/w== X-Received: by 2002:a17:902:c2c3:b0:168:9498:a0f6 with SMTP id c3-20020a170902c2c300b001689498a0f6mr5659009pla.0.1654729606164; Wed, 08 Jun 2022 16:06:46 -0700 (PDT) Original-Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com. [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id d62-20020a623641000000b0051baaa40028sm16000945pfa.11.2022.06.08.16.06.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 08 Jun 2022 16:06:45 -0700 (PDT) In-Reply-To: <83edzz5l70.fsf@gnu.org> Content-Language: en-US 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" Xref: news.gmane.io gmane.emacs.bugs:233997 Archived-At: On 6/8/2022 6:38 AM, Eli Zaretskii wrote: > I don't have any objections based on actual experience, and I don't > know what was the original design goals of this feature in Eshell. > However, please note that you are changing the behavior significantly, > and the only reason is that it doesn't make much sense to you. I probably should have elaborated a bit more on my reasoning in the original report. My goal with this (and other Eshell patches in this area) is mainly to add tests for some of the more-advanced Eshell syntax and also to ensure that it works as documented. There are a few cases where it's tricky to decide whether the code is right and the documentation is wrong, or vice-versa. This is one of those cases. Here's what the Emacs 27/28 manuals have to say about this syntax (I've already changed/expanded this section in 29, so I'm going back to 28 to show what the docs said before I changed them): $var[i] Expands to the ith element of the value bound to var. If the value is a string, it will be split at whitespace to make it a list. Again, raises an error if the value is not a sequence. $var[: i] As above, but now splitting occurs at the colon character. $var[: i j] As above, but instead of returning just a string, it now returns a list of two strings. If the result is being interpolated into a larger string, this list will be flattened into one big string, with each element separated by a space. I would interpret the above to mean that the only splitting that should happen for `$var[: i]' is with the ":". The last section says that `$var[: i]' returns "just a string", and `$var[: i j]' returns a list of two strings. However, in my example in the original message, `$foo[: 0 1]' would return a list containing a list and a string. That's inconsistent with what the manual says, and in this case I think it's the manual that was right, and the code that wasn't. Note: the last sentence in the manual excerpt above is also incorrect. When the list is "flattened into one big string", it will look like '("first" "second")', not 'first second'. Unlike the original bug here, which people probably don't encounter very often in practice, changing how the list is flattened would probably cause problems for users. It's a really common occurrence. Something as simple as `echo a b' will return '("a" "b")'. This problem is also discussed in bug#12689.