From unknown Fri Aug 15 04:04:36 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#49716 <49716@debbugs.gnu.org> To: bug#49716 <49716@debbugs.gnu.org> Subject: Status: no -print0 for ls? Reply-To: bug#49716 <49716@debbugs.gnu.org> Date: Fri, 15 Aug 2025 11:04:36 +0000 retitle 49716 no -print0 for ls? reassign 49716 coreutils submitter 49716 Vito Caputo severity 49716 normal tag 49716 notabug thanks From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 24 05:44:06 2021 Received: (at submit) by debbugs.gnu.org; 24 Jul 2021 09:44:06 +0000 Received: from localhost ([127.0.0.1]:45169 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m7ECQ-0005tV-5c for submit@debbugs.gnu.org; Sat, 24 Jul 2021 05:44:06 -0400 Received: from lists.gnu.org ([209.51.188.17]:37294) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m7Bh3-0001vC-DV for submit@debbugs.gnu.org; Sat, 24 Jul 2021 03:03:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51036) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m7Bh3-0002kb-6M for bug-coreutils@gnu.org; Sat, 24 Jul 2021 03:03:29 -0400 Received: from shells.gnugeneration.com ([66.240.222.126]:58972) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m7Bh1-0001zz-Jp for bug-coreutils@gnu.org; Sat, 24 Jul 2021 03:03:28 -0400 Received: by shells.gnugeneration.com (Postfix, from userid 1000) id 649AD1A572E0; Sat, 24 Jul 2021 00:03:24 -0700 (PDT) Date: Sat, 24 Jul 2021 00:03:24 -0700 From: Vito Caputo To: bug-coreutils@gnu.org Subject: no -print0 for ls? Message-ID: <20210724070324.aarmrjo2zn6j7d6z@shells.gnugeneration.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Received-SPF: pass client-ip=66.240.222.126; envelope-from=swivel@shells.gnugeneration.com; helo=shells.gnugeneration.com X-Spam_score_int: 10 X-Spam_score: 1.0 X-Spam_bar: + X-Spam_report: (1.0 / 5.0 requ) BAYES_50=0.8, HEADER_FROM_DIFFERENT_DOMAINS=0.249, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.1 (-) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Sat, 24 Jul 2021 05:44:01 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.1 (--) Am I going senile here or does ls really not have a `find -print0` equivalent? Thanks, Vito Caputo From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 24 09:22:27 2021 Received: (at 49716) by debbugs.gnu.org; 24 Jul 2021 13:22:27 +0000 Received: from localhost ([127.0.0.1]:45394 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m7Hbn-0007RD-B5 for submit@debbugs.gnu.org; Sat, 24 Jul 2021 09:22:27 -0400 Received: from mail-wm1-f52.google.com ([209.85.128.52]:42680) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m7Hbi-0007Qq-CM; Sat, 24 Jul 2021 09:22:25 -0400 Received: by mail-wm1-f52.google.com with SMTP id j34-20020a05600c1c22b029024e75084404so2318222wms.1; Sat, 24 Jul 2021 06:22:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=rK5nGbae/yVhtREkc2cmN3jlBHu97XfKmE5AjA2LrDc=; b=NX+UR0coT9gXxK2liwKb8OEC9ljOB25ThpL8BfRr9TglrFjIu5MYYtmBFFs7BtjtzY 25JQXGrwqP2rkaNS0MBTJHthoyHyDKXunZwwUDp87RqwFW+PUfCohK8etzG1M37GbNrH jPtDQsf69YkYR6BdpjplIRfitYC58SCzEJ0+V0kAgt6dUuWBwqwjPJljm73dgUBHh8/n DUZK3SJCrVYl9yrDL8BHaz3qZ36rZtnBgBSs4Cvh8+n/1VtjJGjqd5BUKtANLNfySkE3 rsDAi0ZS8ALIU7ULUDpMW368cVLQGSKpRVKmnum55XHQZLPKCuEXlTQgEJflgsXtzZzV 8veg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=rK5nGbae/yVhtREkc2cmN3jlBHu97XfKmE5AjA2LrDc=; b=SONrSTFna7aV3/PRKdOY1PAtdj0fetQzSrp9gMFOb6O713Uet6y8E74U/E89FfyFOt wBPCPUqrIGCr5tkg8Ihvd6Z/BJhDJxJovboFbQfq8V+Xfo9/CUKVtcLPM3zojYfhWP5O kW1Uh/4vmdjlvV7HtcvR0SJiRmNlPifTDw3kvaSl3R27gLPx4m+qrWDm0tFHbvkVdlW7 H2IOzaiMMZpnTOuITL4KOGt+j5/OcghLyAJlbmHEQmzIYO9InzP7nUUtwQD261+Xszms xlRovaWEfIa1OzgqKE/l0eS5uM/Q1jnPnxEOzq80feBVTAn51WRYUySpoRgSwhd90AiC anIg== X-Gm-Message-State: AOAM531hsq1ANmY2cloZvOs6/l6OyQnQssSjuvaXImEKlDnxfsE15Vj2 5EVbvMXGU9MxF5SPpoM6Kl+ctZoYSXlsNw== X-Google-Smtp-Source: ABdhPJyGvJGpmrX6tp7AbWMeredZi+onm1ZM1UM6JhCEMX3zDeVft9gf26KpKhVdGUImr92wOAfXdQ== X-Received: by 2002:a1c:4c16:: with SMTP id z22mr18342425wmf.176.1627132936221; Sat, 24 Jul 2021 06:22:16 -0700 (PDT) Received: from localhost.localdomain (86-42-15-3-dynamic.agg2.lod.rsl-rtd.eircom.net. [86.42.15.3]) by smtp.googlemail.com with UTF8SMTPSA id b12sm36444372wro.1.2021.07.24.06.22.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 24 Jul 2021 06:22:15 -0700 (PDT) Subject: Re: bug#49716: no -print0 for ls? To: Vito Caputo , 49716@debbugs.gnu.org References: <20210724070324.aarmrjo2zn6j7d6z@shells.gnugeneration.com> From: =?UTF-8?Q?P=c3=a1draig_Brady?= Message-ID: <368bf886-37a5-961a-9c66-0d818db205bf@draigBrady.com> Date: Sat, 24 Jul 2021 14:22:14 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Thunderbird/84.0 MIME-Version: 1.0 In-Reply-To: <20210724070324.aarmrjo2zn6j7d6z@shells.gnugeneration.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Score: 0.4 (/) X-Debbugs-Envelope-To: 49716 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.6 (/) tag 49716 notabug close 49716 stop On 24/07/2021 08:03, Vito Caputo wrote: > Am I going senile here or does ls really not have a `find -print0` > equivalent? This was previously discussed as noted at: https://www.gnu.org/software/coreutils/rejected_requests.html#ls In summary, ls output is mainly for non programmatic consumption. Also find also provides this functionality as you say. thanks, Pádraig From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 24 13:05:22 2021 Received: (at 49716) by debbugs.gnu.org; 24 Jul 2021 17:05:22 +0000 Received: from localhost ([127.0.0.1]:46842 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m7L5W-000714-6U for submit@debbugs.gnu.org; Sat, 24 Jul 2021 13:05:22 -0400 Received: from mail-wr1-f53.google.com ([209.85.221.53]:33740) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m7L5R-00070h-S4 for 49716@debbugs.gnu.org; Sat, 24 Jul 2021 13:05:21 -0400 Received: by mail-wr1-f53.google.com with SMTP id q3so5823521wrx.0 for <49716@debbugs.gnu.org>; Sat, 24 Jul 2021 10:05:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=51eChK67T+BW0Mo/bIrCd5neVGCbAxnPhvH3InntHtU=; b=mJonKH71SAlBplBtE25oGxL6Y6BttBItq5z7exATKhsVfRp3//sf2iHQd3gcxX/1Rr s5qx0D59zcMw+7WF7ZEYIRI4y+msc802heCDOQFH7QwiumL/nIa2e3sMbfFJtGTRGwFG 9gHlfOlKKjrdAZzbOaNk5T38eQjcctGTwhKIAK35ey5Wi5O5oumzNfWgMuHs1eqnkIPM W1CRuzQJ6kGtvL1J78Q10i5RJpFOJjKh47dWYRj1Cr5mtipuo8/xXG1a10IZDu9jkMsh zzdxtrnVr3JWpPR7iDHEvMcb1PJRMicPN4CMKhc/SGcCtOkAR2rygVerfkSODJLD5oRQ wDHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=51eChK67T+BW0Mo/bIrCd5neVGCbAxnPhvH3InntHtU=; b=jbIiDAFWI0WlJzEML3kNBhp1+cbV9rPkzHtvOpS23LvifzVf03yq7cmiUXjRnFkCBu Z8v4smRlUlYZ1NDRXhRHEYo/8wNDoWZPVRGerwtlIZIhXEF8lZ2k9a7KU01DG/4BdmAd ZFdMxjWxQ4kj+J5xD+8OuKz8rlQTvW3ZrBSangz1SBHa2SYFNW7uiV8Qekm6iFkhiLHn 8w/7GMnpz8Z2CTBTUxxjuHhYDwdQ47KAuLclM/m23ZxY/t8fEZzNOEny+jpByuX2LPtJ Wh9vwnpTvGFA3UCZm/G4WYWQ8UAqjCxW2Sk80AvY413DlTHqGFoq8rAbV03E8b5Ecjiv TDZA== X-Gm-Message-State: AOAM532YM5BwqGcktN/A5sKn+ecEr24xB5BJkRKjjPVZ84mFdnpYuUrw XlzPI9vwZCDioj7n8NSKyavz9q3ppoP1zg== X-Google-Smtp-Source: ABdhPJzLpBTP+Yaq1Elr6641r8dqUWr3icXvRjsmr1FQn0uYquIKiiiTIe/ME13Z6H7EbNPsGehkww== X-Received: by 2002:a5d:5305:: with SMTP id e5mr10803439wrv.237.1627146311737; Sat, 24 Jul 2021 10:05:11 -0700 (PDT) Received: from localhost.localdomain (86-42-15-3-dynamic.agg2.lod.rsl-rtd.eircom.net. [86.42.15.3]) by smtp.googlemail.com with UTF8SMTPSA id l39sm6893269wms.1.2021.07.24.10.05.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 24 Jul 2021 10:05:11 -0700 (PDT) Subject: Re: bug#49716: no -print0 for ls? To: Vito Caputo References: <20210724070324.aarmrjo2zn6j7d6z@shells.gnugeneration.com> <368bf886-37a5-961a-9c66-0d818db205bf@draigBrady.com> <20210724163459.dtlctjmkgfllz4cq@shells.gnugeneration.com> From: =?UTF-8?Q?P=c3=a1draig_Brady?= Message-ID: Date: Sat, 24 Jul 2021 18:05:10 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Thunderbird/84.0 MIME-Version: 1.0 In-Reply-To: <20210724163459.dtlctjmkgfllz4cq@shells.gnugeneration.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Score: 0.4 (/) X-Debbugs-Envelope-To: 49716 Cc: 49716@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.6 (/) On 24/07/2021 17:34, Vito Caputo wrote: > On Sat, Jul 24, 2021 at 02:22:14PM +0100, Pádraig Brady wrote: >> On 24/07/2021 08:03, Vito Caputo wrote: >>> Am I going senile here or does ls really not have a `find -print0` >>> equivalent? >> >> This was previously discussed as noted at: >> https://www.gnu.org/software/coreutils/rejected_requests.html#ls >> >> In summary, ls output is mainly for non programmatic consumption. >> Also find also provides this functionality as you say. >> > > This isn't really a satisfactory rationale IMNSHO, and the chain of > links you just sent me down is basically a bunch of echoing the same > incredibly weak rationale. > > I recently tripped over this when just wanting to watch a directory of > video files in ascending file size order. A simple `ls -Sr | xargs > mpv` would do the trick, but the filenames turned out to be a real > mess warranting -0. Trivial to add -0 to the xargs, but not so for > the ls command, wasting significant time digging through its man page. > > Are we really expecting a user in this situation to then go read the > find(1) man page and figure out how to prevent it from recursive > operation, produce null termination, *and* sort the results by file > size in ascending order? > > When they already have the exact `ls -Sr` invocation in hand? > > This seems asinine to me, the entire unix philosophy is composable > utilities and ad-hoc pipelines. `ls` is arguably the most familiar > and reflxively used of those utilities. I see no reason to prevent > the user from making its output robust against newlines in pipeline > scenarios like the one described above. Especially considering a > patch has already been submitted to add it... Perhaps it might be useful when ls is just outputting names, but would be then disallow a -z option with -l, because -l has various ambiguities in output leading to non obvious programmatic handling issues. Do your files have '\n' in them? If not you might try: ls -Sr | tr '\n' '\0' | xargs -r0 mpv thanks, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 24 13:38:50 2021 Received: (at 49716) by debbugs.gnu.org; 24 Jul 2021 17:38:50 +0000 Received: from localhost ([127.0.0.1]:46882 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m7Lbt-0001Ym-Pc for submit@debbugs.gnu.org; Sat, 24 Jul 2021 13:38:50 -0400 Received: from shells.gnugeneration.com ([66.240.222.126]:54158) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m7Kc8-0006GM-VO for 49716@debbugs.gnu.org; Sat, 24 Jul 2021 12:35:01 -0400 Received: by shells.gnugeneration.com (Postfix, from userid 1000) id 7C8B31A57457; Sat, 24 Jul 2021 09:34:59 -0700 (PDT) Date: Sat, 24 Jul 2021 09:34:59 -0700 From: Vito Caputo To: =?utf-8?Q?P=C3=A1draig?= Brady Subject: Re: bug#49716: no -print0 for ls? Message-ID: <20210724163459.dtlctjmkgfllz4cq@shells.gnugeneration.com> References: <20210724070324.aarmrjo2zn6j7d6z@shells.gnugeneration.com> <368bf886-37a5-961a-9c66-0d818db205bf@draigBrady.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <368bf886-37a5-961a-9c66-0d818db205bf@draigBrady.com> X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 49716 X-Mailman-Approved-At: Sat, 24 Jul 2021 13:38:47 -0400 Cc: 49716@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) On Sat, Jul 24, 2021 at 02:22:14PM +0100, Pádraig Brady wrote: > On 24/07/2021 08:03, Vito Caputo wrote: > > Am I going senile here or does ls really not have a `find -print0` > > equivalent? > > This was previously discussed as noted at: > https://www.gnu.org/software/coreutils/rejected_requests.html#ls > > In summary, ls output is mainly for non programmatic consumption. > Also find also provides this functionality as you say. > This isn't really a satisfactory rationale IMNSHO, and the chain of links you just sent me down is basically a bunch of echoing the same incredibly weak rationale. I recently tripped over this when just wanting to watch a directory of video files in ascending file size order. A simple `ls -Sr | xargs mpv` would do the trick, but the filenames turned out to be a real mess warranting -0. Trivial to add -0 to the xargs, but not so for the ls command, wasting significant time digging through its man page. Are we really expecting a user in this situation to then go read the find(1) man page and figure out how to prevent it from recursive operation, produce null termination, *and* sort the results by file size in ascending order? When they already have the exact `ls -Sr` invocation in hand? This seems asinine to me, the entire unix philosophy is composable utilities and ad-hoc pipelines. `ls` is arguably the most familiar and reflxively used of those utilities. I see no reason to prevent the user from making its output robust against newlines in pipeline scenarios like the one described above. Especially considering a patch has already been submitted to add it... Thanks, Vito Caputo From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 24 14:10:48 2021 Received: (at 49716) by debbugs.gnu.org; 24 Jul 2021 18:10:48 +0000 Received: from localhost ([127.0.0.1]:46945 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m7M6p-0002Lo-Jq for submit@debbugs.gnu.org; Sat, 24 Jul 2021 14:10:48 -0400 Received: from shells.gnugeneration.com ([66.240.222.126]:54698) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m7Lkv-0001pJ-3H for 49716@debbugs.gnu.org; Sat, 24 Jul 2021 13:48:09 -0400 Received: by shells.gnugeneration.com (Postfix, from userid 1000) id C21851A57465; Sat, 24 Jul 2021 10:48:07 -0700 (PDT) Date: Sat, 24 Jul 2021 10:48:07 -0700 From: Vito Caputo To: =?utf-8?Q?P=C3=A1draig?= Brady Subject: Re: bug#49716: no -print0 for ls? Message-ID: <20210724174807.fb2ue4b53q4ia2k4@shells.gnugeneration.com> References: <20210724070324.aarmrjo2zn6j7d6z@shells.gnugeneration.com> <368bf886-37a5-961a-9c66-0d818db205bf@draigBrady.com> <20210724163459.dtlctjmkgfllz4cq@shells.gnugeneration.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 49716 X-Mailman-Approved-At: Sat, 24 Jul 2021 14:10:46 -0400 Cc: 49716@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) On Sat, Jul 24, 2021 at 06:05:10PM +0100, Pádraig Brady wrote: > On 24/07/2021 17:34, Vito Caputo wrote: > > On Sat, Jul 24, 2021 at 02:22:14PM +0100, Pádraig Brady wrote: > > > On 24/07/2021 08:03, Vito Caputo wrote: > > > > Am I going senile here or does ls really not have a `find -print0` > > > > equivalent? > > > > > > This was previously discussed as noted at: > > > https://www.gnu.org/software/coreutils/rejected_requests.html#ls > > > > > > In summary, ls output is mainly for non programmatic consumption. > > > Also find also provides this functionality as you say. > > > > > > > This isn't really a satisfactory rationale IMNSHO, and the chain of > > links you just sent me down is basically a bunch of echoing the same > > incredibly weak rationale. > > > > I recently tripped over this when just wanting to watch a directory of > > video files in ascending file size order. A simple `ls -Sr | xargs > > mpv` would do the trick, but the filenames turned out to be a real > > mess warranting -0. Trivial to add -0 to the xargs, but not so for > > the ls command, wasting significant time digging through its man page. > > > > Are we really expecting a user in this situation to then go read the > > find(1) man page and figure out how to prevent it from recursive > > operation, produce null termination, *and* sort the results by file > > size in ascending order? > > > > When they already have the exact `ls -Sr` invocation in hand? > > > > This seems asinine to me, the entire unix philosophy is composable > > utilities and ad-hoc pipelines. `ls` is arguably the most familiar > > and reflxively used of those utilities. I see no reason to prevent > > the user from making its output robust against newlines in pipeline > > scenarios like the one described above. Especially considering a > > patch has already been submitted to add it... > > Perhaps it might be useful when ls is just outputting names, > but would be then disallow a -z option with -l, > because -l has various ambiguities in output leading to non obvious programmatic handling issues. > Yes, it only makes sense with plain names in single-column format. But that usage style has significant applicability... Couldn't we make -0 and any aliases shorthand for a new --format=WORD where WORD is names0 or something. That way it's automatically mutually exclusive with the other formats? > Do your files have '\n' in them? If not you might try: > > ls -Sr | tr '\n' '\0' | xargs -r0 mpv > There were newlines in some of the names... It was just one of those situations where you know you have a heap of crazy web-scraped titles, and you have no interest in making assumptions about what is or isn't in there. So you just want nul-terminated strings and to not fret about anything going awry. Thanks, Vito Caputo From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 24 15:26:12 2021 Received: (at 49716) by debbugs.gnu.org; 24 Jul 2021 19:26:12 +0000 Received: from localhost ([127.0.0.1]:47066 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m7NHn-0004Pi-TE for submit@debbugs.gnu.org; Sat, 24 Jul 2021 15:26:12 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:50160) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m7NHl-0004PU-CZ for 49716@debbugs.gnu.org; Sat, 24 Jul 2021 15:26:10 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 2E84A1600EB; Sat, 24 Jul 2021 12:26:03 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 6Ykl67AUS9HT; Sat, 24 Jul 2021 12:26:02 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 6E3741600ED; Sat, 24 Jul 2021 12:26:02 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id QfCbqaD51L6R; Sat, 24 Jul 2021 12:26:02 -0700 (PDT) Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id E61E31600EB; Sat, 24 Jul 2021 12:26:01 -0700 (PDT) To: Vito Caputo , =?UTF-8?Q?P=c3=a1draig_Brady?= References: <20210724070324.aarmrjo2zn6j7d6z@shells.gnugeneration.com> <368bf886-37a5-961a-9c66-0d818db205bf@draigBrady.com> <20210724163459.dtlctjmkgfllz4cq@shells.gnugeneration.com> <20210724174807.fb2ue4b53q4ia2k4@shells.gnugeneration.com> From: Paul Eggert Organization: UCLA Computer Science Department Subject: Re: bug#49716: no -print0 for ls? Message-ID: <73d6ac6a-f70f-295a-2cab-9cd36e827ca4@cs.ucla.edu> Date: Sat, 24 Jul 2021 12:26:01 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210724174807.fb2ue4b53q4ia2k4@shells.gnugeneration.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.4 (--) X-Debbugs-Envelope-To: 49716 Cc: 49716@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.4 (---) On 7/24/21 10:48 AM, Vito Caputo wrote: > Couldn't we make > -0 and any aliases shorthand for a new --format=3DWORD where WORD is > names0 or something. That way it's automatically mutually exclusive > with the other formats? It would make sense to invent a new --quoting-style=3D'literal0' option=20 (by analogy with the existing --quoting-style=3D'literal'), and make ls -= 0=20 an alias for ls --quoting-style=3D'literal0'. I could add support for tha= t=20 if there's interest. From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 25 10:43:15 2021 Received: (at 49716) by debbugs.gnu.org; 25 Jul 2021 14:43:15 +0000 Received: from localhost ([127.0.0.1]:49119 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m7fLX-0006Jb-C3 for submit@debbugs.gnu.org; Sun, 25 Jul 2021 10:43:15 -0400 Received: from mail-wr1-f52.google.com ([209.85.221.52]:35562) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m7fLT-0006JL-8A for 49716@debbugs.gnu.org; Sun, 25 Jul 2021 10:43:13 -0400 Received: by mail-wr1-f52.google.com with SMTP id n12so4265727wrr.2 for <49716@debbugs.gnu.org>; Sun, 25 Jul 2021 07:43:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=NFd33Xh0eRPknAh7opuOEIE52oQ/5f4gmawBWzdkClM=; b=jcBXK2/RwSjFTPO/iZiW1iCdZJ9qYWR68eyBgV5H3UA9jyG1B9PfqBi9+PECml3mf/ 64/T3VFoYAzECxxk/0ZlfoeRZrIk1wVC1hEq4DQni/nbYHxbWzILmgPxpc1TXtBDhClH OwI7xMAIl3p120swFXmHeOK6FV5sdZmycegZTYIIGJqI5bcyTew6qQQv4rwsPUNPaF2o n0HrLE2Cu4Hc5iWlrXNBCUItZjJDnq7EySPXZfoD0cegRSqGC/AUa+glVQNqKBlg7rX9 FjIvaHZl7HxU82d0Pa50NN//ws0HaM3RpDytnKFZqhrlhFP8tBnPI8SlaDvtIfY8sON9 ziNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=NFd33Xh0eRPknAh7opuOEIE52oQ/5f4gmawBWzdkClM=; b=S/wf8l00Tm5dJCag9DvEeiYy5qMp2i030/PsL93pcoNfJve0kMR8nDm5QPJgqUSKy4 aSR6wr4kYzunqeDMbndc++jcEK7nENPcqjCPxP61tRMtfAcixGGSbKdnc1UrGCAlfEVS Nr5hZmxJ9qE5OPXTjMbN8fVGXml8StgP38vWnpVMeMmdWth2iR0E5sgQvree6WiOCD1/ udKj5NUdP1y9l+Q3+VnZcBfYAzfMGVb62PXYSIrFFdvdGIv1+DthZVpycpDjvbNS/oyX FBO7VqyzxWnL0QAvjEClsCN+kl4O+cCAOJy1yXUAjIM7rpij36rzf/xq6LdbqnaOhZQN kpHw== X-Gm-Message-State: AOAM531dQCB6rh+aGzlM7tvlgGNIu7076vb+5gCxQXSr/5a8TEoS/DtT KM0eeNcarjnr7BVWfoFHfkayuFONWSk= X-Google-Smtp-Source: ABdhPJyvzO9DgLxpn0FPW6wJBj/+c4czKn6PuWIVWKsRuVfhfzlS/ie+g7oxLhZCYNil66JmnA2L4g== X-Received: by 2002:a5d:4fc6:: with SMTP id h6mr14845324wrw.112.1627224184988; Sun, 25 Jul 2021 07:43:04 -0700 (PDT) Received: from localhost.localdomain (86-42-15-3-dynamic.agg2.lod.rsl-rtd.eircom.net. [86.42.15.3]) by smtp.googlemail.com with UTF8SMTPSA id h4sm2098088wru.2.2021.07.25.07.43.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 25 Jul 2021 07:43:04 -0700 (PDT) Subject: Re: bug#49716: no -print0 for ls? To: Paul Eggert , Vito Caputo References: <20210724070324.aarmrjo2zn6j7d6z@shells.gnugeneration.com> <368bf886-37a5-961a-9c66-0d818db205bf@draigBrady.com> <20210724163459.dtlctjmkgfllz4cq@shells.gnugeneration.com> <20210724174807.fb2ue4b53q4ia2k4@shells.gnugeneration.com> <73d6ac6a-f70f-295a-2cab-9cd36e827ca4@cs.ucla.edu> From: =?UTF-8?Q?P=c3=a1draig_Brady?= Message-ID: Date: Sun, 25 Jul 2021 15:43:03 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Thunderbird/84.0 MIME-Version: 1.0 In-Reply-To: <73d6ac6a-f70f-295a-2cab-9cd36e827ca4@cs.ucla.edu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Score: 0.4 (/) X-Debbugs-Envelope-To: 49716 Cc: 49716@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.6 (/) On 24/07/2021 20:26, Paul Eggert wrote: > On 7/24/21 10:48 AM, Vito Caputo wrote: >> Couldn't we make >> -0 and any aliases shorthand for a new --format=WORD where WORD is >> names0 or something. That way it's automatically mutually exclusive >> with the other formats? > > It would make sense to invent a new --quoting-style='literal0' option > (by analogy with the existing --quoting-style='literal'), and make ls -0 > an alias for ls --quoting-style='literal0'. I could add support for that > if there's interest. It's one of those marginal ones I think, but if you think it's warranted, that's cool. I would use the more consistent option for this though, i.e.: -z, --zero end each output line with NUL, not newline We could document that -z implies: --quoting-style=literal --show-control-chars --format=single-column The --format=single-column implication is debatable. I'm suggesting it as robust programmatic parsing of --format=long is pretty much impossible, which is not obvious. thanks, Pádraig From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 25 11:28:17 2021 Received: (at 49716) by debbugs.gnu.org; 25 Jul 2021 15:28:18 +0000 Received: from localhost ([127.0.0.1]:49166 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m7g37-0007SS-KO for submit@debbugs.gnu.org; Sun, 25 Jul 2021 11:28:17 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:41348) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m7g34-0007SD-3P for 49716@debbugs.gnu.org; Sun, 25 Jul 2021 11:28:16 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 0343B1600C3; Sun, 25 Jul 2021 08:28:08 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 0OsuYCw-UFjF; Sun, 25 Jul 2021 08:28:07 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 4D6C91600DB; Sun, 25 Jul 2021 08:28:07 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id S4T7XjKzaWwe; Sun, 25 Jul 2021 08:28:07 -0700 (PDT) Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 25C3F1600C3; Sun, 25 Jul 2021 08:28:07 -0700 (PDT) To: =?UTF-8?Q?P=c3=a1draig_Brady?= , Vito Caputo References: <20210724070324.aarmrjo2zn6j7d6z@shells.gnugeneration.com> <368bf886-37a5-961a-9c66-0d818db205bf@draigBrady.com> <20210724163459.dtlctjmkgfllz4cq@shells.gnugeneration.com> <20210724174807.fb2ue4b53q4ia2k4@shells.gnugeneration.com> <73d6ac6a-f70f-295a-2cab-9cd36e827ca4@cs.ucla.edu> From: Paul Eggert Organization: UCLA Computer Science Department Subject: Re: bug#49716: no -print0 for ls? Message-ID: <1ccd5c7a-afb8-706d-80aa-9a00128f2674@cs.ucla.edu> Date: Sun, 25 Jul 2021 08:28:06 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.4 (--) X-Debbugs-Envelope-To: 49716 Cc: 49716@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.4 (---) On 7/25/21 7:43 AM, P=C3=A1draig Brady wrote: > I would use the more consistent option for this though, i.e.: >=20 > =C2=A0 -z, --zero=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 end each out= put line with NUL, not newline That's a different option, no? My proposal was something that would=20 affect every program using --quoting-style, and it would quote=20 individual filenames and suchlike. The --zero option, in contrast, would=20 mean 'ls' would output NUL every place it normally outputs a newline as=20 part of the own format that it generates. These are different things. It sounds like your approach is better than what I proposed, though. --null makes sense, but I'm not entirely sold on having a short option=20 for this rarely-needed functionality. Perhaps it'd be better to add it=20 with just the long name for now. If it gets used a lot we could add a=20 short alias later. From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 25 13:10:23 2021 Received: (at submit) by debbugs.gnu.org; 25 Jul 2021 17:10:23 +0000 Received: from localhost ([127.0.0.1]:49299 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m7hdv-0001Wr-0u for submit@debbugs.gnu.org; Sun, 25 Jul 2021 13:10:23 -0400 Received: from lists.gnu.org ([209.51.188.17]:46972) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m7hds-0001Wj-Uk for submit@debbugs.gnu.org; Sun, 25 Jul 2021 13:10:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58836) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m7hds-00087O-P4 for bug-coreutils@gnu.org; Sun, 25 Jul 2021 13:10:20 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:46849) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m7hdr-0000fr-5X for bug-coreutils@gnu.org; Sun, 25 Jul 2021 13:10:20 -0400 Received: by mail-wr1-x436.google.com with SMTP id w12so8065056wro.13 for ; Sun, 25 Jul 2021 10:10:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=bH4Rl6labFQynbZxfMGAUw+9LGePkshgRWGML04+cug=; b=i0nwy0dy1leApdiwkCiZ5CYZUD7uthnmaNOJXsTlvPIUJLAv8YKPI8dL0qq4YpCo7j CM9MA9yse/M0jUeTjjUnMFd4k3J/maSn3q8QDz3UcBPromS/xDIc6tyn61CwAWcHQ3Xn lwjB5UOjHznYuekK3PYoVya4aR5eRRnSGhZwYUQ/sbTZceaihVWzKufixQEk9ygwpDEv 8noqXSqvHm8F78pUb4wTzoyMRPUL39wyUnIORqjr7x5ZMhoAW/Mfi/8kA2I6H69CXoRT cksovhclnXQSftlY5cewFTWw7vlKqi7w/szpQ9otY03++Mp0qDvK8iPB2GqXpJ//p9q1 cE6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=bH4Rl6labFQynbZxfMGAUw+9LGePkshgRWGML04+cug=; b=CxAxkKd0PtAB+8tjKgC1sWzhDz3tvGGw0niNyBhlfnGbXqtMHojv0MrRgZj3op3NVb sSPZZFeIXV19pplbQGn+a4LVXdQCrpj+CQ9MhfY+HcoW3mRMxiVOp2N9as8Wh5axQuvX 0f0eUyTMW/C60+9e52Ho718Q9G1vnB9nvMdky/mePUC1yKO+f+lLZJTFag9/89XjsPX3 76UXDcoTdx6QBBj6y3xFNdCQHDCqPKKvRtRiSnVKIxyOdApLZQ09GYLPC1yBBLBK7ARD QtiSLHiloHRhgssMo/L2qQf0Q3IvUoZmA9WCmiuP40a6HJYd2QwKI9BbeJFviznB7bou xU5A== X-Gm-Message-State: AOAM532pfd7k0fjeKiovGb/IbAGd35INLEwnPLsS8QeEa6cxsxguNWsZ r4Pa/QHWY1ktRQyuom/bFo8vX54O5Nc= X-Google-Smtp-Source: ABdhPJz+VP2Omv1CWTyQGoAWqPXAmwh3zUhoFHpd89eQpJjYbqtsED1H994af0Wp6XZkSQc86ugJJg== X-Received: by 2002:a5d:6d89:: with SMTP id l9mr14894346wrs.371.1627233016522; Sun, 25 Jul 2021 10:10:16 -0700 (PDT) Received: from localhost.localdomain (86-42-15-3-dynamic.agg2.lod.rsl-rtd.eircom.net. [86.42.15.3]) by smtp.googlemail.com with UTF8SMTPSA id d15sm40249675wri.39.2021.07.25.10.10.15 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 25 Jul 2021 10:10:15 -0700 (PDT) Subject: Re: bug#49716: no -print0 for ls? To: bug-coreutils@gnu.org References: <20210724070324.aarmrjo2zn6j7d6z@shells.gnugeneration.com> <368bf886-37a5-961a-9c66-0d818db205bf@draigBrady.com> <20210724163459.dtlctjmkgfllz4cq@shells.gnugeneration.com> <20210724174807.fb2ue4b53q4ia2k4@shells.gnugeneration.com> <73d6ac6a-f70f-295a-2cab-9cd36e827ca4@cs.ucla.edu> <1ccd5c7a-afb8-706d-80aa-9a00128f2674@cs.ucla.edu> From: =?UTF-8?Q?P=c3=a1draig_Brady?= Message-ID: Date: Sun, 25 Jul 2021 18:10:14 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Thunderbird/84.0 MIME-Version: 1.0 In-Reply-To: <1ccd5c7a-afb8-706d-80aa-9a00128f2674@cs.ucla.edu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=pixelbeat@gmail.com; helo=mail-wr1-x436.google.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, NICE_REPLY_A=-1.091, 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: -0.9 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.9 (-) On 25/07/2021 16:28, Paul Eggert wrote: > On 7/25/21 7:43 AM, Pádraig Brady wrote: >> I would use the more consistent option for this though, i.e.: >> >>   -z, --zero                    end each output line with NUL, not newline > > That's a different option, no? My proposal was something that would > affect every program using --quoting-style, and it would quote > individual filenames and suchlike. The --zero option, in contrast, would > mean 'ls' would output NUL every place it normally outputs a newline as > part of the own format that it generates. These are different things. > > It sounds like your approach is better than what I proposed, though. > > --null makes sense, but I'm not entirely sold on having a short option > for this rarely-needed functionality. Perhaps it'd be better to add it > with just the long name for now. If it gets used a lot we could add a > short alias later. Right we should be especially careful of short options with ls. A long only option should suffice cheers, Pádraig From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 26 04:06:20 2021 Received: (at 49716) by debbugs.gnu.org; 26 Jul 2021 08:06:20 +0000 Received: from localhost ([127.0.0.1]:49877 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m7vcn-0007z1-Cb for submit@debbugs.gnu.org; Mon, 26 Jul 2021 04:06:20 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:59066) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m7vci-0007yU-9Y for 49716@debbugs.gnu.org; Mon, 26 Jul 2021 04:06:08 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 23C33160083; Mon, 26 Jul 2021 01:05:58 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id U-1wyHLF4wOI; Mon, 26 Jul 2021 01:05:52 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 2F02D1600DB; Mon, 26 Jul 2021 01:05:52 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id pDB-aRIJop5o; Mon, 26 Jul 2021 01:05:51 -0700 (PDT) Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id D4987160083; Mon, 26 Jul 2021 01:05:51 -0700 (PDT) To: =?UTF-8?Q?P=c3=a1draig_Brady?= References: <20210724070324.aarmrjo2zn6j7d6z@shells.gnugeneration.com> <368bf886-37a5-961a-9c66-0d818db205bf@draigBrady.com> <20210724163459.dtlctjmkgfllz4cq@shells.gnugeneration.com> <20210724174807.fb2ue4b53q4ia2k4@shells.gnugeneration.com> <73d6ac6a-f70f-295a-2cab-9cd36e827ca4@cs.ucla.edu> <1ccd5c7a-afb8-706d-80aa-9a00128f2674@cs.ucla.edu> From: Paul Eggert Organization: UCLA Computer Science Department Subject: Re: bug#49716: no -print0 for ls? Message-ID: <37d3f590-50ee-4c03-df0d-72f3d72a346c@cs.ucla.edu> Date: Mon, 26 Jul 2021 01:05:50 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------495408A2CFF03BB9F0482094" Content-Language: en-US X-Spam-Score: -2.4 (--) X-Debbugs-Envelope-To: 49716 Cc: Vito Caputo , 49716@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.1 (-) This is a multi-part message in MIME format. --------------495408A2CFF03BB9F0482094 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable On 7/25/21 10:10 AM, P=C3=A1draig Brady wrote: > Right we should be especially careful of short options with ls. > A long only option should suffice OK, I installed the attached to implement 'ls --null'. (The last patch=20 is the actual change; the other patches are cleanups.) This addresses=20 the problem raised in the bug report. Is there any pattern as to why some coreutils programs have a --null=20 option and others have a --zero option? The two options seem to mean the=20 same thing. Should we work toward standardizing on one spelling or the=20 other (of course maintaining backward compatibility). --------------495408A2CFF03BB9F0482094 Content-Type: text/x-patch; charset=UTF-8; name="0001-env-fix-usage-typo.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-env-fix-usage-typo.patch" =46rom 3753c706b7ccd756db955e850175b79f22911d57 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 17 Jul 2021 15:07:29 -0500 Subject: [PATCH 1/7] env: fix usage typo * src/env.c (usage): Fix pluralization typo. --- src/env.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/env.c b/src/env.c index 5a30696d9..685c24adb 100644 --- a/src/env.c +++ b/src/env.c @@ -141,7 +141,7 @@ Set each NAME to VALUE in the environment and run COM= MAND.\n\ --default-signal[=3DSIG] reset handling of SIG signal(s) to the d= efault\n\ "), stdout); fputs (_("\ - --ignore-signal[=3DSIG] set handling of SIG signals(s) to do not= hing\n\ + --ignore-signal[=3DSIG] set handling of SIG signal(s) to do noth= ing\n\ "), stdout); fputs (_("\ --list-signal-handling list non default signal handling to stderr= \n\ --=20 2.30.2 --------------495408A2CFF03BB9F0482094 Content-Type: text/x-patch; charset=UTF-8; name="0002-maint-fix-white-space.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0002-maint-fix-white-space.patch" =46rom 5622ab450e2402570cef48a5fed0eb0b4523b264 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 18 Jul 2021 00:12:29 -0500 Subject: [PATCH 2/7] maint: fix white space --- configure.ac | 23 +++++--- m4/jm-macros.m4 | 4 +- src/dd.c | 2 +- src/expand.c | 2 +- src/factor.c | 143 ++++++++++++++++++++++++----------------------- src/set-fields.c | 24 ++++---- src/stdbuf.c | 2 +- src/unexpand.c | 2 +- 8 files changed, 105 insertions(+), 97 deletions(-) diff --git a/configure.ac b/configure.ac index c4d8ec0b6..6960b486a 100644 --- a/configure.ac +++ b/configure.ac @@ -287,7 +287,8 @@ void unset_TZ (void) if (! (to[0][0] =3D=3D 'T' && to[0][1] =3D=3D 'Z' && to[0][2] =3D=3D= '=3D')) to++; } -int main() +int +main () { time_t now =3D time ((time_t *) 0); int hour_GMT0, hour_unset; @@ -529,10 +530,11 @@ AC_LINK_IFELSE( [AC_LANG_SOURCE([[ #include =20 - int main(void) + int + main (void) { unsigned int eax, ebx, ecx, edx; - __get_cpuid(1, &eax, &ebx, &ecx, &edx); + __get_cpuid (1, &eax, &ebx, &ecx, &edx); return 1; } ]]) @@ -551,10 +553,11 @@ AC_COMPILE_IFELSE( [AC_LANG_SOURCE([[ #include =20 - int main(void) + int + main (void) { __m128i a, b; - a =3D _mm_clmulepi64_si128(a, b, 0x00); + a =3D _mm_clmulepi64_si128 (a, b, 0x00); return 1; } ]]) @@ -580,10 +583,11 @@ AC_LINK_IFELSE( [AC_LANG_SOURCE([[ #include =20 - int main(void) + int + main (void) { unsigned int eax =3D 0, ebx =3D 0, ecx =3D 0, edx =3D 0; - __get_cpuid_count(7, 0, &eax, &ebx, &ecx, &edx); + __get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx); return 1; } ]]) @@ -600,10 +604,11 @@ AC_COMPILE_IFELSE( [AC_LANG_SOURCE([[ #include =20 - int main(void) + int + main (void) { __m256i a, b; - a =3D _mm256_sad_epu8(a, b); + a =3D _mm256_sad_epu8 (a, b); return 1; } ]]) diff --git a/m4/jm-macros.m4 b/m4/jm-macros.m4 index fb66907f4..8ae9edf6c 100644 --- a/m4/jm-macros.m4 +++ b/m4/jm-macros.m4 @@ -1,4 +1,4 @@ -#serial 113 -*- autoconf -*- +#serial 114 -*- autoconf -*- =20 dnl Misc type-related macros for coreutils. =20 @@ -164,7 +164,7 @@ AC_DEFUN([coreutils_MACROS], [[#include ]], [[#ifdef __i386__ - fpsetprec(FP_PE); + fpsetprec (FP_PE); #else # error not required on 64 bit #endif diff --git a/src/dd.c b/src/dd.c index fc5108f8b..06be4b04e 100644 --- a/src/dd.c +++ b/src/dd.c @@ -1037,7 +1037,7 @@ quit (int code) } =20 /* Return LEN rounded down to a multiple of IO_BUFSIZE - (to minimize calls to the expensive posix_fadvise(,POSIX_FADV_DONTNEE= D), + (to minimize calls to the expensive posix_fadvise (,POSIX_FADV_DONTNE= ED), while storing the remainder internally per FD. Pass LEN =3D=3D 0 to get the current remainder. */ =20 diff --git a/src/expand.c b/src/expand.c index dd9d2981a..4e32bfcbb 100644 --- a/src/expand.c +++ b/src/expand.c @@ -227,7 +227,7 @@ main (int argc, char **argv) =20 finalize_tab_stops (); =20 - set_file_list ( (optind < argc) ? &argv[optind] : NULL); + set_file_list ((optind < argc) ? &argv[optind] : NULL); =20 expand (); =20 diff --git a/src/factor.c b/src/factor.c index d1a6bb8e7..62a269fcf 100644 --- a/src/factor.c +++ b/src/factor.c @@ -265,10 +265,10 @@ static void factor (uintmax_t, uintmax_t, struct fa= ctors *); __x2 =3D (uintmax_t) __uh * __vl; = \ __x3 =3D (uintmax_t) __uh * __vh; = \ = \ - __x1 +=3D __ll_highpart (__x0);/* this can't give carry */ = \ - __x1 +=3D __x2; /* but this indeed can */ = \ - if (__x1 < __x2) /* did we get it? */ = \ - __x3 +=3D __ll_B; /* yes, add it in the proper pos. */ = \ + __x1 +=3D __ll_highpart (__x0);/* This can't give carry. */ \ + __x1 +=3D __x2; /* But this indeed can. */ \ + if (__x1 < __x2) /* Did we get it? */ \ + __x3 +=3D __ll_B; /* Yes, add it in the proper pos. */ \ = \ (w1) =3D __x3 + __ll_highpart (__x1); = \ (w0) =3D (__x1 << W_TYPE_SIZE / 2) + __ll_lowpart (__x0); = \ @@ -276,9 +276,9 @@ static void factor (uintmax_t, uintmax_t, struct fact= ors *); #endif =20 #if !defined udiv_qrnnd || defined UDIV_NEEDS_NORMALIZATION -/* Define our own, not needing normalization. This function is - currently not performance critical, so keep it simple. Similar to - the mod macro below. */ +/* Define our own, not needing normalization. This function is + currently not performance critical, so keep it simple. Similar to + the mod macro below. */ # undef udiv_qrnnd # define udiv_qrnnd(q, r, n1, n0, d) = \ do { = \ @@ -433,7 +433,7 @@ mod2 (uintmax_t *r1, uintmax_t a1, uintmax_t a0, uint= max_t d1, uintmax_t d0) static uintmax_t _GL_ATTRIBUTE_CONST gcd_odd (uintmax_t a, uintmax_t b) { - if ( (b & 1) =3D=3D 0) + if ((b & 1) =3D=3D 0) { uintmax_t t =3D b; b =3D a; @@ -473,7 +473,7 @@ gcd2_odd (uintmax_t *r1, uintmax_t a1, uintmax_t a0, = uintmax_t b1, uintmax_t b0) { assert (b0 & 1); =20 - if ( (a0 | a1) =3D=3D 0) + if ((a0 | a1) =3D=3D 0) { *r1 =3D b1; return b0; @@ -699,7 +699,7 @@ static bool dev_debug =3D false; /* Prove primality or run probabilistic tests. */ static bool flag_prove_primality =3D PROVE_PRIMALITY; =20 -/* Number of Miller-Rabin tests to run when not proving primality. */ +/* Number of Miller-Rabin tests to run when not proving primality. */ #define MR_REPS 25 =20 static void @@ -713,22 +713,22 @@ factor_insert_refind (struct factors *factors, uint= max_t p, unsigned int i, =20 /* Trial division with odd primes uses the following trick. =20 - Let p be an odd prime, and B =3D 2^{W_TYPE_SIZE}. For simplicity, + Let p be an odd prime, and B =3D 2^{W_TYPE_SIZE}. For simplicity, consider the case t < B (this is the second loop below). =20 From our tables we get =20 binv =3D p^{-1} (mod B) - lim =3D floor ( (B-1) / p ). + lim =3D floor ((B-1) / p). =20 - First assume that t is a multiple of p, t =3D q * p. Then 0 <=3D q <=3D= lim + First assume that t is a multiple of p, t =3D q * p. Then 0 <=3D q <= =3D lim (and all quotients in this range occur for some t). =20 Then t =3D q * p is true also (mod B), and p is invertible we get =20 q =3D t * binv (mod B). =20 - Next, assume that t is *not* divisible by p. Since multiplication + Next, assume that t is *not* divisible by p. Since multiplication by binv (mod B) is a one-to-one mapping, =20 t * binv (mod B) > lim, @@ -914,7 +914,7 @@ static const unsigned char binvert_table[128] =3D _q0 =3D (u0) * _di; = \ if ((u1) >=3D (d)) = \ { = \ - uintmax_t _p1, _p0 _GL_UNUSED; \ + uintmax_t _p1, _p0 _GL_UNUSED; \ umul_ppmm (_p1, _p0, _q0, d); = \ (q1) =3D ((u1) - _p1) * _di; = \ (q0) =3D _q0; = \ @@ -926,14 +926,14 @@ static const unsigned char binvert_table[128] =3D } = \ } while (0) =20 -/* x B (mod n). */ +/* x B (mod n). */ #define redcify(r_prim, r, n) = \ do { = \ - uintmax_t _redcify_q _GL_UNUSED; \ + uintmax_t _redcify_q _GL_UNUSED; \ udiv_qrnnd (_redcify_q, r_prim, r, 0, n); = \ } while (0) =20 -/* x B^2 (mod n). Requires x > 0, n1 < B/2 */ +/* x B^2 (mod n). Requires x > 0, n1 < B/2. */ #define redcify2(r1, r0, x, n1, n0) = \ do { = \ uintmax_t _r1, _r0, _i; = \ @@ -958,7 +958,7 @@ static const unsigned char binvert_table[128] =3D } while (0) =20 /* Modular two-word multiplication, r =3D a * b mod m, with mi =3D m^(-1= ) mod B. - Both a and b must be in redc form, the result will be in redc form to= o. */ + Both a and b must be in redc form, the result will be in redc form to= o. */ static inline uintmax_t mulredc (uintmax_t a, uintmax_t b, uintmax_t m, uintmax_t mi) { @@ -976,7 +976,7 @@ mulredc (uintmax_t a, uintmax_t b, uintmax_t m, uintm= ax_t mi) =20 /* Modular two-word multiplication, r =3D a * b mod m, with mi =3D m^(-1= ) mod B. Both a and b must be in redc form, the result will be in redc form to= o. - For performance reasons, the most significant bit of m must be clear.= */ + For performance reasons, the most significant bit of m must be clear.= */ static uintmax_t mulredc2 (uintmax_t *r1p, uintmax_t a1, uintmax_t a0, uintmax_t b1, uintmax_t b0, @@ -984,9 +984,9 @@ mulredc2 (uintmax_t *r1p, { uintmax_t r1, r0, q, p1, p0 _GL_UNUSED, t1, t0, s1, s0; mi =3D -mi; - assert ( (a1 >> (W_TYPE_SIZE - 1)) =3D=3D 0); - assert ( (b1 >> (W_TYPE_SIZE - 1)) =3D=3D 0); - assert ( (m1 >> (W_TYPE_SIZE - 1)) =3D=3D 0); + assert ((a1 >> (W_TYPE_SIZE - 1)) =3D=3D 0); + assert ((b1 >> (W_TYPE_SIZE - 1)) =3D=3D 0); + assert ((m1 >> (W_TYPE_SIZE - 1)) =3D=3D 0); =20 /* First compute a0 * B^{-1} +-----+ @@ -1112,7 +1112,7 @@ millerrabin (uintmax_t n, uintmax_t ni, uintmax_t b= , uintmax_t q, { uintmax_t y =3D powm (b, q, n, ni, one); =20 - uintmax_t nm1 =3D n - one; /* -1, but in redc representation. */ + uintmax_t nm1 =3D n - one; /* -1, but in redc representation. */= =20 if (y =3D=3D one || y =3D=3D nm1) return true; @@ -1192,7 +1192,7 @@ prime_p (uintmax_t n) if (n <=3D 1) return false; =20 - /* We have already casted out small primes. */ + /* We have already casted out small primes. */ if (n < (uintmax_t) FIRST_OMITTED_PRIME * FIRST_OMITTED_PRIME) return true; =20 @@ -1231,7 +1231,7 @@ prime_p (uintmax_t n) } else { - /* After enough Miller-Rabin runs, be content. */ + /* After enough Miller-Rabin runs, be content. */ is_prime =3D (r =3D=3D MR_REPS - 1); } =20 @@ -1298,7 +1298,7 @@ prime2_p (uintmax_t n1, uintmax_t n0) redcify2 (one[1], one[0], 1, n1, n0); addmod2 (a_prim[1], a_prim[0], one[1], one[0], one[1], one[0], n1, n0)= ; =20 - /* FIXME: Use scalars or pointers in arguments? Some consistency neede= d. */ + /* FIXME: Use scalars or pointers in arguments? Some consistency need= ed. */ na[0] =3D n0; na[1] =3D n1; =20 @@ -1332,9 +1332,9 @@ prime2_p (uintmax_t n1, uintmax_t n0) } for (unsigned int i =3D 0; i < factors.nfactors && is_prime; i= ++) { - /* FIXME: We always have the factor 2. Do we really need t= o - handle it here? We have done the same powering as part - of millerrabin. */ + /* FIXME: We always have the factor 2. Do we really need = to + handle it here? We have done the same powering as part= + of millerrabin. */ if (factors.p[i] =3D=3D 2) rsh2 (e[1], e[0], nm1[1], nm1[0], 1); else @@ -1345,7 +1345,7 @@ prime2_p (uintmax_t n1, uintmax_t n0) } else { - /* After enough Miller-Rabin runs, be content. */ + /* After enough Miller-Rabin runs, be content. */ is_prime =3D (r =3D=3D MR_REPS - 1); } =20 @@ -1373,7 +1373,7 @@ mp_prime_p (mpz_t n) if (mpz_cmp_ui (n, 1) <=3D 0) return false; =20 - /* We have already casted out small primes. */ + /* We have already casted out small primes. */ if (mpz_cmp_ui (n, (long) FIRST_OMITTED_PRIME * FIRST_OMITTED_PRIME) <= 0) return true; =20 @@ -1418,7 +1418,7 @@ mp_prime_p (mpz_t n) } else { - /* After enough Miller-Rabin runs, be content. */ + /* After enough Miller-Rabin runs, be content. */ is_prime =3D (r =3D=3D MR_REPS - 1); } =20 @@ -1463,7 +1463,7 @@ factor_using_pollard_rho (uintmax_t n, unsigned lon= g int a, { assert (a < n); =20 - binv (ni, n); /* FIXME: when could we use old 'ni' val= ue? */ + binv (ni, n); /* FIXME: when could we use old 'ni' val= ue? */ =20 for (;;) { @@ -1598,7 +1598,7 @@ factor_using_pollard_rho2 (uintmax_t n1, uintmax_t = n0, unsigned long int a, =20 if (g1 =3D=3D 0) { - /* The found factor is one word, and > 1. */ + /* The found factor is one word, and > 1. */ divexact_21 (n1, n0, n1, n0, g0); /* n =3D n / g */ =20 if (!prime_p (g0)) @@ -1619,9 +1619,12 @@ factor_using_pollard_rho2 (uintmax_t n1, uintmax_t= n0, unsigned long int a, return; } =20 - binv (ginv, g0); /* Compute n =3D n / g. Since the resul= t will */ - n0 =3D ginv * n0; /* fit one word, we can compute the qu= otient */ - n1 =3D 0; /* modulo B, ignoring the high divisor= word. */ + /* Compute n =3D n / g. Since the result will fit one word, + we can compute the quotient modulo B, ignoring the high + divisor word. */ + binv (ginv, g0); + n0 =3D ginv * n0; + n1 =3D 0; =20 if (!prime2_p (g1, g0)) factor_using_pollard_rho2 (g1, g0, a + 1, factors); @@ -1747,7 +1750,7 @@ mp_factor_using_pollard_rho (mpz_t n, unsigned long= int a, =20 #if USE_SQUFOF /* FIXME: Maybe better to use an iteration converging to 1/sqrt(n)? If - algorithm is replaced, consider also returning the remainder. */ + algorithm is replaced, consider also returning the remainder. */ static uintmax_t _GL_ATTRIBUTE_CONST isqrt (uintmax_t n) { @@ -1758,7 +1761,7 @@ isqrt (uintmax_t n) =20 count_leading_zeros (c, n); =20 - /* Make x > sqrt(n). This will be invariant through the loop. */ + /* Make x > sqrt(n). This will be invariant through the loop. */ x =3D (uintmax_t) 1 << ((W_TYPE_SIZE + 1 - c) / 2); =20 for (;;) @@ -1777,7 +1780,7 @@ isqrt2 (uintmax_t nh, uintmax_t nl) unsigned int shift; uintmax_t x; =20 - /* Ensures the remainder fits in an uintmax_t. */ + /* Ensures the remainder fits in an uintmax_t. */ assert (nh < ((uintmax_t) 1 << (W_TYPE_SIZE - 2))); =20 if (nh =3D=3D 0) @@ -1786,11 +1789,11 @@ isqrt2 (uintmax_t nh, uintmax_t nl) count_leading_zeros (shift, nh); shift &=3D ~1; =20 - /* Make x > sqrt(n) */ - x =3D isqrt ( (nh << shift) + (nl >> (W_TYPE_SIZE - shift))) + 1; + /* Make x > sqrt (n). */ + x =3D isqrt ((nh << shift) + (nl >> (W_TYPE_SIZE - shift))) + 1; x <<=3D (W_TYPE_SIZE - shift) / 2; =20 - /* Do we need more than one iteration? */ + /* Do we need more than one iteration? */ for (;;) { uintmax_t r _GL_UNUSED; @@ -1816,21 +1819,21 @@ isqrt2 (uintmax_t nh, uintmax_t nl) } } =20 -/* MAGIC[N] has a bit i set iff i is a quadratic residue mod N. */ +/* MAGIC[N] has a bit i set iff i is a quadratic residue mod N. */ # define MAGIC64 0x0202021202030213ULL # define MAGIC63 0x0402483012450293ULL # define MAGIC65 0x218a019866014613ULL # define MAGIC11 0x23b =20 -/* Return the square root if the input is a square, otherwise 0. */ +/* Return the square root if the input is a square, otherwise 0. */ static uintmax_t _GL_ATTRIBUTE_CONST is_square (uintmax_t x) { - /* Uses the tests suggested by Cohen. Excludes 99% of the non-squares = before - computing the square root. */ + /* Uses the tests suggested by Cohen. Excludes 99% of the non-squares= before + computing the square root. */ if (((MAGIC64 >> (x & 63)) & 1) && ((MAGIC63 >> (x % 63)) & 1) - /* Both 0 and 64 are squares mod (65) */ + /* Both 0 and 64 are squares mod (65). */ && ((MAGIC65 >> ((x % 65) & 63)) & 1) && ((MAGIC11 >> (x % 11) & 1))) { @@ -1841,7 +1844,7 @@ is_square (uintmax_t x) return 0; } =20 -/* invtab[i] =3D floor(0x10000 / (0x100 + i) */ +/* invtab[i] =3D floor (0x10000 / (0x100 + i) */ static const unsigned short invtab[0x81] =3D { 0x200, @@ -1888,7 +1891,7 @@ static const unsigned short invtab[0x81] =3D _mask =3D -(uintmax_t) (_r >=3D (d)); = \ (r) =3D _r - (_mask & (d)); = \ (q) =3D _q - _mask; = \ - assert ( (q) * (d) + (r) =3D=3D u); = \ + assert ((q) * (d) + (r) =3D=3D u); \ } = \ else = \ { = \ @@ -1898,7 +1901,7 @@ static const unsigned short invtab[0x81] =3D } = \ } while (0) =20 -/* Notes: Example N =3D 22117019. After first phase we find Q1 =3D 6314,= Q +/* Notes: Example N =3D 22117019. After first phase we find Q1 =3D 6314= , Q =3D 3025, P =3D 1737, representing F_{18} =3D (-6314, 2* 1737, 3025),= with 3025 =3D 55^2. =20 @@ -1945,7 +1948,7 @@ static unsigned int q_freq[Q_FREQ_SIZE + 1]; =20 #if USE_SQUFOF /* Return true on success. Expected to fail only for numbers - >=3D 2^{2*W_TYPE_SIZE - 2}, or close to that limit. */ + >=3D 2^{2*W_TYPE_SIZE - 2}, or close to that limit. */ static bool factor_using_squfof (uintmax_t n1, uintmax_t n0, struct factors *factors= ) { @@ -2016,7 +2019,7 @@ factor_using_squfof (uintmax_t n1, uintmax_t n0, st= ruct factors *factors) assert (mu * n0 % 4 =3D=3D 3); =20 /* In the notation of the paper, with mu * n =3D=3D 3 (mod 4), we - get \Delta =3D 4 mu * n, and the paper's \mu is 2 mu. As far as= + get \Delta =3D 4 mu * n, and the paper's \mu is 2 mu. As far a= s I understand it, the necessary bound is 4 \mu^3 < n, or 32 mu^3 < n. =20 @@ -2024,7 +2027,7 @@ factor_using_squfof (uintmax_t n1, uintmax_t n0, st= ruct factors *factors) 105, we get a trivial factor, from the square 38809 =3D 197^2, without any corresponding Q earlier in the iteration. =20 - Requiring 64 mu^3 < n seems sufficient. */ + Requiring 64 mu^3 < n seems sufficient. */ if (n1 =3D=3D 0) { if ((uintmax_t) mu*mu*mu >=3D n0 / 64) @@ -2046,15 +2049,15 @@ factor_using_squfof (uintmax_t n1, uintmax_t n0, = struct factors *factors) Q1 =3D 1; P =3D S; =20 - /* Square root remainder fits in one word, so ignore high part. */= + /* Square root remainder fits in one word, so ignore high part. *= / Q =3D Dl - P*P; - /* FIXME: When can this differ from floor(sqrt(2 sqrt(D)))? */ + /* FIXME: When can this differ from floor (sqrt (2 * sqrt (D)))? = */ L =3D isqrt (2*S); B =3D 2*L; L1 =3D mu * 2 * L; =20 /* The form is (+/- Q1, 2P, -/+ Q), of discriminant 4 (P^2 + Q Q1)= =3D - 4 D. */ + 4 D. */ =20 for (i =3D 0; i <=3D B; i++) { @@ -2074,7 +2077,7 @@ factor_using_squfof (uintmax_t n1, uintmax_t n0, st= ruct factors *factors) { uintmax_t g =3D Q; =20 - if ( (Q & 1) =3D=3D 0) + if ((Q & 1) =3D=3D 0) g /=3D 2; =20 g /=3D gcd_odd (g, mu); @@ -2090,13 +2093,13 @@ factor_using_squfof (uintmax_t n1, uintmax_t n0, = struct factors *factors) } =20 /* I think the difference can be either sign, but mod - 2^W_TYPE_SIZE arithmetic should be fine. */ + 2^W_TYPE_SIZE arithmetic should be fine. */ t =3D Q1 + q * (P - P1); Q1 =3D Q; Q =3D t; P =3D P1; =20 - if ( (i & 1) =3D=3D 0) + if ((i & 1) =3D=3D 0) { uintmax_t r =3D is_square (Q); if (r) @@ -2106,10 +2109,10 @@ factor_using_squfof (uintmax_t n1, uintmax_t n0, = struct factors *factors) if (queue[j].Q =3D=3D r) { if (r =3D=3D 1) - /* Traversed entire cycle. */ + /* Traversed entire cycle. */ goto next_multiplier; =20 - /* Need the absolute value for divisibility te= st. */ + /* Need the absolute value for divisibility te= st. */ if (P >=3D queue[j].P) t =3D P - queue[j].P; else @@ -2117,7 +2120,7 @@ factor_using_squfof (uintmax_t n1, uintmax_t n0, st= ruct factors *factors) if (t % r =3D=3D 0) { /* Delete entries up to and including entr= y - j, which matched. */ + j, which matched. */ memmove (queue, queue + j + 1, (qpos - j - 1) * sizeof (queue[0]= )); qpos -=3D (j + 1); @@ -2127,15 +2130,15 @@ factor_using_squfof (uintmax_t n1, uintmax_t n0, = struct factors *factors) } =20 /* We have found a square form, which should give a - factor. */ + factor. */ Q1 =3D r; - assert (S >=3D P); /* What signs are possible? */ + assert (S >=3D P); /* What signs are possible? */ P +=3D r * ((S - P) / r); =20 /* Note: Paper says (N - P*P) / Q1, that seems incorre= ct - for the case D =3D 2N. */ + for the case D =3D 2N. */ /* Compute Q =3D (D - P*P) / Q1, but we need double - precision. */ + precision. */ uintmax_t hi, lo; umul_ppmm (hi, lo, P, P); sub_ddmmss (hi, lo, Dh, Dl, hi, lo); @@ -2148,7 +2151,7 @@ factor_using_squfof (uintmax_t n1, uintmax_t n0, st= ruct factors *factors) Step 4a in the algorithm description says q <--= floor([S+P]/\hat Q), but looking at the equatio= ns in Sec. 3.1, it should be q <-- floor([S+P] / Q= ). - (In this code, \hat Q is Q1). */ + (In this code, \hat Q is Q1). */ div_smallq (q, rem, S+P, Q); P1 =3D S - rem; /* P1 =3D q*Q - P */ =20 @@ -2164,7 +2167,7 @@ factor_using_squfof (uintmax_t n1, uintmax_t n0, st= ruct factors *factors) P =3D P1; } =20 - if ( (Q & 1) =3D=3D 0) + if ((Q & 1) =3D=3D 0) Q /=3D 2; Q /=3D gcd_odd (Q, mu); =20 diff --git a/src/set-fields.c b/src/set-fields.c index 42f6c2189..a214ff21e 100644 --- a/src/set-fields.c +++ b/src/set-fields.c @@ -162,17 +162,17 @@ set_fields (char const *fieldstr, unsigned int opti= ons) in_digits =3D false; /* Starting a range. */ if (dash_found) - FATAL_ERROR ( (options & SETFLD_ERRMSG_USE_POS) - ?_("invalid byte or character range") - :_("invalid field range")); + FATAL_ERROR ((options & SETFLD_ERRMSG_USE_POS) + ? _("invalid byte or character range") + : _("invalid field range")); =20 dash_found =3D true; fieldstr++; =20 if (lhs_specified && !value) - FATAL_ERROR ( (options & SETFLD_ERRMSG_USE_POS) - ?_("byte/character positions are numbered from= 1") - :_("fields are numbered from 1")); + FATAL_ERROR ((options & SETFLD_ERRMSG_USE_POS) + ? _("byte/character positions are numbered from= 1") + : _("fields are numbered from 1")); =20 initial =3D (lhs_specified ? value : 1); value =3D 0; @@ -216,9 +216,9 @@ set_fields (char const *fieldstr, unsigned int option= s) { /* A simple field number, not a range. */ if (value =3D=3D 0) - FATAL_ERROR ( (options & SETFLD_ERRMSG_USE_POS) - ?_("byte/character positions are numbered = from 1") - :_("fields are numbered from 1")); + FATAL_ERROR ((options & SETFLD_ERRMSG_USE_POS) + ? _("byte/character positions are numbered = from 1") + : _("fields are numbered from 1")); =20 add_range_pair (value, value); value =3D 0; @@ -275,9 +275,9 @@ set_fields (char const *fieldstr, unsigned int option= s) } =20 if (!n_frp) - FATAL_ERROR ( (options&SETFLD_ERRMSG_USE_POS) - ?_("missing list of byte/character positions") - :_("missing list of fields")); + FATAL_ERROR ((options&SETFLD_ERRMSG_USE_POS) + ? _("missing list of byte/character positions") + : _("missing list of fields")); =20 qsort (frp, n_frp, sizeof (frp[0]), compare_ranges); =20 diff --git a/src/stdbuf.c b/src/stdbuf.c index dd39bd086..e8a0b6123 100644 --- a/src/stdbuf.c +++ b/src/stdbuf.c @@ -129,7 +129,7 @@ and are thus unaffected by 'stdbuf' settings.\n\ /* argv[0] can be anything really, but generally it contains the path to the executable or just a name if it was executed using $PATH. In the latter case to get the path we can: - search getenv("PATH"), readlink("/prof/self/exe"), getenv("_"), + search getenv ("PATH"), readlink ("/prof/self/exe"), getenv ("_"), dladdr(), pstat_getpathname(), etc. */ =20 static void diff --git a/src/unexpand.c b/src/unexpand.c index db0b74f24..cec392d6c 100644 --- a/src/unexpand.c +++ b/src/unexpand.c @@ -315,7 +315,7 @@ main (int argc, char **argv) =20 finalize_tab_stops (); =20 - set_file_list ( (optind < argc) ? &argv[optind] : NULL); + set_file_list ((optind < argc) ? &argv[optind] : NULL); =20 unexpand (); =20 --=20 2.30.2 --------------495408A2CFF03BB9F0482094 Content-Type: text/x-patch; charset=UTF-8; name="0003-build-update-gnulib-submodule-to-latest.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0003-build-update-gnulib-submodule-to-latest.patch" =46rom 558959daa9fb04095c40153c494b5977ab675160 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 17 Jul 2021 15:47:56 -0500 Subject: [PATCH 3/7] build: update gnulib submodule to latest --- gnulib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnulib b/gnulib index ff7c8b21e..ec87cff2a 160000 --- a/gnulib +++ b/gnulib @@ -1 +1 @@ -Subproject commit ff7c8b21e259fdc4bc721ed55519cfee06739efa +Subproject commit ec87cff2ac13f29f4aee88caa7e16e72cef3f490 --=20 2.30.2 --------------495408A2CFF03BB9F0482094 Content-Type: text/x-patch; charset=UTF-8; name="0004-ls-simplify-sprintf-usage.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0004-ls-simplify-sprintf-usage.patch" =46rom c09b25dd3f83f2db6d6dde57146b2ba747073308 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 25 Jul 2021 18:54:10 -0700 Subject: [PATCH 4/7] ls: simplify sprintf usage * src/ls.c (format_user_or_group_width, print_long_format): Use return value from sprintf instead of calling strlen on the resulting buffer, or inferring the length some other way. --- src/ls.c | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/src/ls.c b/src/ls.c index 1b20f17fe..a73aaf022 100644 --- a/src/ls.c +++ b/src/ls.c @@ -4227,8 +4227,7 @@ format_user_or_group_width (char const *name, unsig= ned long int id) else { char buf[INT_BUFSIZE_BOUND (id)]; - sprintf (buf, "%lu", id); - return strlen (buf); + return sprintf (buf, "%lu", id); } } =20 @@ -4322,11 +4321,8 @@ print_long_format (const struct fileinfo *f) if (print_inode) { char hbuf[INT_BUFSIZE_BOUND (uintmax_t)]; - sprintf (p, "%*s ", inode_number_width, - format_inode (hbuf, sizeof hbuf, f)); - /* Increment by strlen (p) here, rather than by inode_number_width= + 1. - The latter is wrong when inode_number_width is zero. */ - p +=3D strlen (p); + p +=3D sprintf (p, "%*s ", inode_number_width, + format_inode (hbuf, sizeof hbuf, f)); } =20 if (print_block_size) @@ -4349,13 +4345,9 @@ print_long_format (const struct fileinfo *f) "optional alternate access method flag". */ { char hbuf[INT_BUFSIZE_BOUND (uintmax_t)]; - sprintf (p, "%s %*s ", modebuf, nlink_width, - ! f->stat_ok ? "?" : umaxtostr (f->stat.st_nlink, hbuf)); + p +=3D sprintf (p, "%s %*s ", modebuf, nlink_width, + ! f->stat_ok ? "?" : umaxtostr (f->stat.st_nlink, hbuf= )); } - /* Increment by strlen (p) here, rather than by, e.g., - sizeof modebuf - 2 + any_has_acl + 1 + nlink_width + 1. - The latter is wrong when nlink_width is zero. */ - p +=3D strlen (p); =20 DIRED_INDENT (); =20 @@ -4386,12 +4378,11 @@ print_long_format (const struct fileinfo *f) int blanks_width =3D (file_size_width - (major_device_number_width + 2 + minor_device_number_width)); - sprintf (p, "%*s, %*s ", - major_device_number_width + MAX (0, blanks_width), - umaxtostr (major (f->stat.st_rdev), majorbuf), - minor_device_number_width, - umaxtostr (minor (f->stat.st_rdev), minorbuf)); - p +=3D file_size_width + 1; + p +=3D sprintf (p, "%*s, %*s ", + major_device_number_width + MAX (0, blanks_width), + umaxtostr (major (f->stat.st_rdev), majorbuf), + minor_device_number_width, + umaxtostr (minor (f->stat.st_rdev), minorbuf)); } else { @@ -4454,12 +4445,11 @@ print_long_format (const struct fileinfo *f) /* The time cannot be converted using the desired format, so print it as a huge integer number of seconds. */ char hbuf[INT_BUFSIZE_BOUND (intmax_t)]; - sprintf (p, "%*s ", long_time_expected_width (), - (! f->stat_ok || ! btime_ok - ? "?" - : timetostr (when_timespec.tv_sec, hbuf))); + p +=3D sprintf (p, "%*s ", long_time_expected_width (), + (! f->stat_ok || ! btime_ok + ? "?" + : timetostr (when_timespec.tv_sec, hbuf))); /* FIXME: (maybe) We discarded when_timespec.tv_nsec. */ - p +=3D strlen (p); } =20 DIRED_FPUTS (buf, stdout, p - buf); --=20 2.30.2 --------------495408A2CFF03BB9F0482094 Content-Type: text/x-patch; charset=UTF-8; name="0005-ls-demacroize.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0005-ls-demacroize.patch" =46rom 0a41ad2cfb6aa7af21f40fc870a0b917410b1d4b Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 25 Jul 2021 21:01:31 -0700 Subject: [PATCH 5/7] ls: demacroize MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit Prefer functions or constants to macros where either will do. That=E2=80=99s cleaner, and nowadays there=E2=80=99s no performance reaso= n to prefer macros. All uses changed. * src/ls.c (INITIAL_TABLE_SIZE, MIN_COLUMN_WIDTH): Now constants instead of macros. (file_or_link_mode): New function, replacing the old macro FILE_OR_LINK_MODE. (dired_outbyte): New function, replacing the old macro DIRED_PUTCHAR. (dired_outbuf): New function, replacing the old macro DIRED_FPUTS. (dired_outstring): New function, replacing the old macro DIRED_FPUTS_LITERAL. (dired_indent): New function, replacing the old macro DIRED_INDENT. (push_current_dired_pos): New function, replacing the old macro PUSH_CURRENT_DIRED_POS. (assert_matching_dev_ino): New function, replacing the old macro ASSERT_MATCHING_DEV_INO. (do_stat, do_lstat, stat_for_mode, stat_for_ino, fstat_for_ino) (signal_init, signal_restore, cmp_ctime, cmp_mtime, cmp_atime) (cmp_btime, cmp_size, cmp_name, cmp_extension) (fileinfo_name_width, cmp_width, cmp_version): No longer inline; compilers can deduce this well enough nowadays. (main): Protect unused assert with =E2=80=98if (false)=E2=80=99 rather th= an commenting it out, so that the compiler checks the code. (print_dir): Output the space and newline in the same buffer as the human-readable number they surround. (dirfirst_check): New function, replacing the old macro DIRFIRST_CHECK. Simplify by using subtraction. (off_cmp): New function, replacing the old macro longdiff. (print_long_format): No need to null-terminate the string now. (format_user_or_group): Let printf count the bytes. --- src/ls.c | 275 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 140 insertions(+), 135 deletions(-) diff --git a/src/ls.c b/src/ls.c index a73aaf022..efb87e405 100644 --- a/src/ls.c +++ b/src/ls.c @@ -135,10 +135,6 @@ #define obstack_chunk_alloc malloc #define obstack_chunk_free free =20 -/* Return an int indicating the result of comparing two integers. - Subtracting doesn't always work, due to overflow. */ -#define longdiff(a, b) ((a) < (b) ? -1 : (a) > (b)) - /* Unix-based readdir implementations have historically returned a diren= t.d_ino value that is sometimes not equal to the stat-obtained st_ino value f= or that same entry. This error occurs for a readdir entry that refers @@ -316,7 +312,7 @@ static size_t quote_name_width (char const *name, =20 /* Initial size of hash table. Most hierarchies are likely to be shallower than this. */ -#define INITIAL_TABLE_SIZE 30 +enum { INITIAL_TABLE_SIZE =3D 30 }; =20 /* The set of 'active' directories, from the current command-line argume= nt to the level in the hierarchy at which files are being listed. @@ -366,9 +362,12 @@ static bool color_symlink_as_referent; static char const *hostname; =20 /* mode of appropriate file for colorization */ -#define FILE_OR_LINK_MODE(File) \ - ((color_symlink_as_referent && (File)->linkok) \ - ? (File)->linkmode : (File)->stat.st_mode) +static mode_t +file_or_link_mode (struct fileinfo const *file) +{ + return (color_symlink_as_referent && file->linkok + ? file->linkmode : file->stat.st_mode); +} =20 =20 /* Record of one pending directory waiting to be listed. */ @@ -965,33 +964,43 @@ static size_t max_idx; =20 /* The minimum width of a column is 3: 1 character for the name and 2 for the separating white space. */ -#define MIN_COLUMN_WIDTH 3 +enum { MIN_COLUMN_WIDTH =3D 3 }; =20 =20 -/* This zero-based index is used solely with the --dired option. - When that option is in effect, this counter is incremented for each - byte of output generated by this program so that the beginning +/* This zero-based index is for the --dired option. It is incremented + for each byte of output generated by this program so that the beginni= ng and ending indices (in that output) of every file name can be recorde= d and later output themselves. */ static size_t dired_pos; =20 -#define DIRED_PUTCHAR(c) do {putchar ((c)); ++dired_pos;} while (0) +static void +dired_outbyte (char c) +{ + dired_pos++; + putchar (c); +} =20 -/* Write S to STREAM and increment DIRED_POS by S_LEN. */ -#define DIRED_FPUTS(s, stream, s_len) \ - do {fputs (s, stream); dired_pos +=3D s_len;} while (0) +/* Output the buffer S, of length S_LEN, and increment DIRED_POS by S_LE= N. */ +static void +dired_outbuf (char const *s, size_t s_len) +{ + dired_pos +=3D s_len; + fwrite (s, sizeof *s, s_len, stdout); +} =20 -/* Like DIRED_FPUTS, but for use when S is a literal string. */ -#define DIRED_FPUTS_LITERAL(s, stream) \ - do {fputs (s, stream); dired_pos +=3D sizeof (s) - 1;} while (0) +/* Output the string S, and increment DIRED_POS by its length. */ +static void +dired_outstring (char const *s) +{ + dired_outbuf (s, strlen (s)); +} =20 -#define DIRED_INDENT() \ - do \ - { \ - if (dired) \ - DIRED_FPUTS_LITERAL (" ", stdout); \ - } \ - while (0) +static void +dired_indent (void) +{ + if (dired) + dired_outstring (" "); +} =20 /* With --dired, store pairs of beginning and ending indices of file nam= es. */ static struct obstack dired_obstack; @@ -1004,13 +1013,12 @@ static struct obstack dired_obstack; static struct obstack subdired_obstack; =20 /* Save the current index on the specified obstack, OBS. */ -#define PUSH_CURRENT_DIRED_POS(obs) \ - do \ - { \ - if (dired) \ - obstack_grow (obs, &dired_pos, sizeof (dired_pos)); \ - } \ - while (0) +static void +push_current_dired_pos (struct obstack *obs) +{ + if (dired) + obstack_grow (obs, &dired_pos, sizeof dired_pos); +} =20 /* With -R, this stack is used to help detect directory cycles. The device/inode pairs on this stack mirror the pairs in the @@ -1047,18 +1055,15 @@ dev_ino_pop (void) return *di; } =20 -/* Note the use commented out below: -#define ASSERT_MATCHING_DEV_INO(Name, Di) \ - do \ - { \ - struct stat sb; \ - assert (Name); \ - assert (0 <=3D stat (Name, &sb)); \ - assert (sb.st_dev =3D=3D Di.st_dev); \ - assert (sb.st_ino =3D=3D Di.st_ino); \ - } \ - while (0) -*/ +static void +assert_matching_dev_ino (char const *name, struct dev_ino di) +{ + struct stat sb; + assert (name); + assert (0 <=3D stat (name, &sb)); + assert (sb.st_dev =3D=3D di.st_dev); + assert (sb.st_ino =3D=3D di.st_ino); +} =20 /* Write to standard output PREFIX, followed by the quoting style and a space-separated list of the integers stored in OS all on one line. = */ @@ -1181,62 +1186,62 @@ do_statx (int fd, char const *name, struct stat *= st, int flags, return ret; } =20 -static inline int +static int do_stat (char const *name, struct stat *st) { return do_statx (AT_FDCWD, name, st, 0, calc_req_mask ()); } =20 -static inline int +static int do_lstat (char const *name, struct stat *st) { return do_statx (AT_FDCWD, name, st, AT_SYMLINK_NOFOLLOW, calc_req_mas= k ()); } =20 -static inline int +static int stat_for_mode (char const *name, struct stat *st) { return do_statx (AT_FDCWD, name, st, 0, STATX_MODE); } =20 /* dev+ino should be static, so no need to sync with backing store */ -static inline int +static int stat_for_ino (char const *name, struct stat *st) { return do_statx (AT_FDCWD, name, st, 0, STATX_INO); } =20 -static inline int +static int fstat_for_ino (int fd, struct stat *st) { return do_statx (fd, "", st, AT_EMPTY_PATH, STATX_INO); } #else -static inline int +static int do_stat (char const *name, struct stat *st) { return stat (name, st); } =20 -static inline int +static int do_lstat (char const *name, struct stat *st) { return lstat (name, st); } =20 -static inline int +static int stat_for_mode (char const *name, struct stat *st) { return stat (name, st); } =20 -static inline int +static int stat_for_ino (char const *name, struct stat *st) { return stat (name, st); } =20 -static inline int +static int fstat_for_ino (int fd, struct stat *st) { return fstat (fd, st); @@ -1614,13 +1619,13 @@ signal_setup (bool init) } } =20 -static inline void +static void signal_init (void) { signal_setup (true); } =20 -static inline void +static void signal_restore (void) { signal_setup (false); @@ -1756,7 +1761,7 @@ main (int argc, char **argv) { print_current_files (); if (pending_dirs) - DIRED_PUTCHAR ('\n'); + dired_outbyte ('\n'); } else if (n_files <=3D 1 && pending_dirs && pending_dirs->next =3D=3D 0= ) print_dir_name =3D false; @@ -1776,7 +1781,8 @@ main (int argc, char **argv) entry from the active_dir_set hash table. */ struct dev_ino di =3D dev_ino_pop (); struct dev_ino *found =3D hash_remove (active_dir_set, &di= ); - /* ASSERT_MATCHING_DEV_INO (thispend->realname, di); */ + if (false) + assert_matching_dev_ino (thispend->realname, di); assert (found); dev_ino_free (found); free_pending_ent (thispend); @@ -2957,9 +2963,9 @@ print_dir (char const *name, char const *realname, = bool command_line_arg) if (recursive || print_dir_name) { if (!first) - DIRED_PUTCHAR ('\n'); + dired_outbyte ('\n'); first =3D false; - DIRED_INDENT (); + dired_indent (); =20 char *absolute_name =3D NULL; if (print_hyperlink) @@ -2974,7 +2980,7 @@ print_dir (char const *name, char const *realname, = bool command_line_arg) =20 free (absolute_name); =20 - DIRED_FPUTS_LITERAL (":\n", stdout); + dired_outstring (":\n"); } =20 /* Read the directory entries, and insert the subfiles into the 'cwd_f= ile' @@ -3059,17 +3065,15 @@ print_dir (char const *name, char const *realname= , bool command_line_arg) =20 if (format =3D=3D long_format || print_block_size) { - char const *p; - char buf[LONGEST_HUMAN_READABLE + 1]; - - DIRED_INDENT (); - p =3D _("total"); - DIRED_FPUTS (p, stdout, strlen (p)); - DIRED_PUTCHAR (' '); - p =3D human_readable (total_blocks, buf, human_output_opts, - ST_NBLOCKSIZE, output_block_size); - DIRED_FPUTS (p, stdout, strlen (p)); - DIRED_PUTCHAR ('\n'); + char buf[LONGEST_HUMAN_READABLE + 3]; + char *p =3D human_readable (total_blocks, buf + 1, human_output_op= ts, + ST_NBLOCKSIZE, output_block_size); + char *pend =3D p + strlen (p); + *--p =3D ' '; + *pend++ =3D '\n'; + dired_indent (); + dired_outstring (_("total")); + dired_outbuf (p, pend - p); } =20 if (cwd_n_used) @@ -3777,20 +3781,14 @@ xstrcoll (char const *a, char const *b) typedef void const *V; typedef int (*qsortFunc)(V a, V b); =20 -/* Used below in DEFINE_SORT_FUNCTIONS for _df_ sort function variants. - The do { ... } while(0) makes it possible to use the macro more like - a statement, without violating C89 rules: */ -#define DIRFIRST_CHECK(a, b) \ - do \ - { \ - bool a_is_dir =3D is_linked_directory ((struct fileinfo const *) a= );\ - bool b_is_dir =3D is_linked_directory ((struct fileinfo const *) b= );\ - if (a_is_dir && !b_is_dir) \ - return -1; /* a goes before b */ \ - if (!a_is_dir && b_is_dir) \ - return 1; /* b goes before a */ \ - } \ - while (0) +/* Used below in DEFINE_SORT_FUNCTIONS for _df_ sort function variants. = */ +static int +dirfirst_check (struct fileinfo const *a, struct fileinfo const *b, + int (*cmp) (V, V)) +{ + int diff =3D is_linked_directory (b) - is_linked_directory (a); + return diff ? diff : cmp (a, b); +} =20 /* Define the 8 different sort function variants required for each sortk= ey. KEY_NAME is a token describing the sort key, e.g., ctime, atime, size= =2E @@ -3812,17 +3810,17 @@ typedef int (*qsortFunc)(V a, V b); = \ /* direct, dirfirst versions */ \ static int xstrcoll_df_##key_name (V a, V b) \ - { DIRFIRST_CHECK (a, b); return key_cmp_func (a, b, xstrcoll); } \ + { return dirfirst_check (a, b, xstrcoll_##key_name); } \ static int _GL_ATTRIBUTE_PURE strcmp_df_##key_name (V a, V b) \ - { DIRFIRST_CHECK (a, b); return key_cmp_func (a, b, strcmp); } \ + { return dirfirst_check (a, b, strcmp_##key_name); } \ = \ /* reverse, dirfirst versions */ \ static int rev_xstrcoll_df_##key_name (V a, V b) \ - { DIRFIRST_CHECK (a, b); return key_cmp_func (b, a, xstrcoll); } \ + { return dirfirst_check (a, b, rev_xstrcoll_##key_name); } \ static int _GL_ATTRIBUTE_PURE rev_strcmp_df_##key_name (V a, V b) \ - { DIRFIRST_CHECK (a, b); return key_cmp_func (b, a, strcmp); } + { return dirfirst_check (a, b, rev_strcmp_##key_name); } =20 -static inline int +static int cmp_ctime (struct fileinfo const *a, struct fileinfo const *b, int (*cmp) (char const *, char const *)) { @@ -3831,7 +3829,7 @@ cmp_ctime (struct fileinfo const *a, struct fileinf= o const *b, return diff ? diff : cmp (a->name, b->name); } =20 -static inline int +static int cmp_mtime (struct fileinfo const *a, struct fileinfo const *b, int (*cmp) (char const *, char const *)) { @@ -3840,7 +3838,7 @@ cmp_mtime (struct fileinfo const *a, struct fileinf= o const *b, return diff ? diff : cmp (a->name, b->name); } =20 -static inline int +static int cmp_atime (struct fileinfo const *a, struct fileinfo const *b, int (*cmp) (char const *, char const *)) { @@ -3849,7 +3847,7 @@ cmp_atime (struct fileinfo const *a, struct fileinf= o const *b, return diff ? diff : cmp (a->name, b->name); } =20 -static inline int +static int cmp_btime (struct fileinfo const *a, struct fileinfo const *b, int (*cmp) (char const *, char const *)) { @@ -3858,15 +3856,21 @@ cmp_btime (struct fileinfo const *a, struct filei= nfo const *b, return diff ? diff : cmp (a->name, b->name); } =20 -static inline int +static int +off_cmp (off_t a, off_t b) +{ + return a < b ? -1 : a > b; +} + +static int cmp_size (struct fileinfo const *a, struct fileinfo const *b, int (*cmp) (char const *, char const *)) { - int diff =3D longdiff (b->stat.st_size, a->stat.st_size); + int diff =3D off_cmp (b->stat.st_size, a->stat.st_size); return diff ? diff : cmp (a->name, b->name); } =20 -static inline int +static int cmp_name (struct fileinfo const *a, struct fileinfo const *b, int (*cmp) (char const *, char const *)) { @@ -3876,7 +3880,7 @@ cmp_name (struct fileinfo const *a, struct fileinfo= const *b, /* Compare file extensions. Files with no extension are 'smallest'. If extensions are the same, compare by file names instead. */ =20 -static inline int +static int cmp_extension (struct fileinfo const *a, struct fileinfo const *b, int (*cmp) (char const *, char const *)) { @@ -3889,7 +3893,7 @@ cmp_extension (struct fileinfo const *a, struct fil= einfo const *b, /* Return the (cached) screen width, for the NAME associated with the passed fileinfo F. */ =20 -static inline size_t +static size_t fileinfo_name_width (struct fileinfo const *f) { return f->width @@ -3897,7 +3901,7 @@ fileinfo_name_width (struct fileinfo const *f) : quote_name_width (f->name, filename_quoting_options, f->quote= d); } =20 -static inline int +static int cmp_width (struct fileinfo const *a, struct fileinfo const *b, int (*cmp) (char const *, char const *)) { @@ -3923,20 +3927,32 @@ DEFINE_SORT_FUNCTIONS (width, cmp_width) because they all use a string comparison (either as the primary or se= condary sort key), and xstrcoll has the ability to do a longjmp if strcoll fa= ils for locale reasons. Lastly, filevercmp is ALWAYS available with gnulib. = */ -static inline int +static int cmp_version (struct fileinfo const *a, struct fileinfo const *b) { return filevercmp (a->name, b->name); } =20 -static int xstrcoll_version (V a, V b) -{ return cmp_version (a, b); } -static int rev_xstrcoll_version (V a, V b) -{ return cmp_version (b, a); } -static int xstrcoll_df_version (V a, V b) -{ DIRFIRST_CHECK (a, b); return cmp_version (a, b); } -static int rev_xstrcoll_df_version (V a, V b) -{ DIRFIRST_CHECK (a, b); return cmp_version (b, a); } +static int +xstrcoll_version (V a, V b) +{ + return cmp_version (a, b); +} +static int +rev_xstrcoll_version (V a, V b) +{ + return cmp_version (b, a); +} +static int +xstrcoll_df_version (V a, V b) +{ + return dirfirst_check (a, b, xstrcoll_version); +} +static int +rev_xstrcoll_df_version (V a, V b) +{ + return dirfirst_check (a, b, rev_xstrcoll_version); +} =20 =20 /* We have 2^3 different variants for each sort-key function @@ -4111,7 +4127,7 @@ print_current_files (void) { set_normal_color (); print_long_format (sorted_file[i]); - DIRED_PUTCHAR ('\n'); + dired_outbyte ('\n'); } break; } @@ -4173,26 +4189,18 @@ long_time_expected_width (void) static void format_user_or_group (char const *name, unsigned long int id, int width)= { - size_t len; - if (name) { int width_gap =3D width - mbswidth (name, 0); int pad =3D MAX (0, width_gap); - fputs (name, stdout); - len =3D strlen (name) + pad; + dired_outstring (name); =20 do - putchar (' '); + dired_outbyte (' '); while (pad--); } else - { - printf ("%*lu ", width, id); - len =3D width; - } - - dired_pos +=3D len + 1; + dired_pos +=3D printf ("%*lu ", width, id); } =20 /* Print the name or id of the user with id U, using a print width of @@ -4349,11 +4357,11 @@ print_long_format (const struct fileinfo *f) ! f->stat_ok ? "?" : umaxtostr (f->stat.st_nlink, hbuf= )); } =20 - DIRED_INDENT (); + dired_indent (); =20 if (print_owner || print_group || print_author || print_scontext) { - DIRED_FPUTS (buf, stdout, p - buf); + dired_outbuf (buf, p - buf); =20 if (print_owner) format_user (f->stat.st_uid, owner_width, f->stat_ok); @@ -4424,7 +4432,7 @@ print_long_format (const struct fileinfo *f) six_months_ago.tv_nsec =3D current_time.tv_nsec; =20 recent =3D (timespec_cmp (six_months_ago, when_timespec) < 0 - && (timespec_cmp (when_timespec, current_time) < 0)); + && timespec_cmp (when_timespec, current_time) < 0); =20 /* We assume here that all time zones are offset from UTC by a whole number of seconds. */ @@ -4436,9 +4444,6 @@ print_long_format (const struct fileinfo *f) { p +=3D s; *p++ =3D ' '; - - /* NUL-terminate the string -- fputs (via DIRED_FPUTS) requires it= =2E */ - *p =3D '\0'; } else { @@ -4452,14 +4457,14 @@ print_long_format (const struct fileinfo *f) /* FIXME: (maybe) We discarded when_timespec.tv_nsec. */ } =20 - DIRED_FPUTS (buf, stdout, p - buf); + dired_outbuf (buf, p - buf); size_t w =3D print_name_with_quoting (f, false, &dired_obstack, p - bu= f); =20 if (f->filetype =3D=3D symbolic_link) { if (f->linkname) { - DIRED_FPUTS_LITERAL (" -> ", stdout); + dired_outstring (" -> "); print_name_with_quoting (f, true, NULL, (p - buf) + w + 4); if (indicator_style !=3D none) print_type_indicator (true, f->linkmode, unknown); @@ -4727,7 +4732,7 @@ quote_name (char const *name, struct quoting_option= s const *options, needs_general_quoting, NULL, &pad); =20 if (pad && allow_pad) - DIRED_PUTCHAR (' '); + dired_outbyte (' '); =20 if (color) print_color_indicator (color); @@ -4756,14 +4761,14 @@ quote_name (char const *name, struct quoting_opti= ons const *options, } =20 if (stack) - PUSH_CURRENT_DIRED_POS (stack); + push_current_dired_pos (stack); =20 fwrite (buf + skip_quotes, 1, len - (skip_quotes * 2), stdout); =20 dired_pos +=3D len; =20 if (stack) - PUSH_CURRENT_DIRED_POS (stack); + push_current_dired_pos (stack); =20 if (absolute_name) { @@ -4898,7 +4903,7 @@ print_type_indicator (bool stat_ok, mode_t mode, en= um filetype type) { char c =3D get_type_indicator (stat_ok, mode, type); if (c) - DIRED_PUTCHAR (c); + dired_outbyte (c); return !!c; } =20 @@ -4939,7 +4944,7 @@ get_color_indicator (const struct fileinfo *f, bool= symlink_target) else { name =3D f->name; - mode =3D FILE_OR_LINK_MODE (f); + mode =3D file_or_link_mode (f); linkok =3D f->linkok; } =20 --=20 2.30.2 --------------495408A2CFF03BB9F0482094 Content-Type: text/x-patch; charset=UTF-8; name="0006-ls-port-to-wider-off_t-uid_t-gid_t.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0006-ls-port-to-wider-off_t-uid_t-gid_t.patch" =46rom 39673b6d4cffe6315d2a572c3741777b3f6a3d28 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 26 Jul 2021 00:26:32 -0700 Subject: [PATCH 6/7] ls: port to wider off_t, uid_t, gid_t * src/ls.c (dired_pos): Now off_t, not size_t, since it counts output file offsets. (dired_dump_obstack): This obstack's file offsets are now off_t, not size_t. (format_user_or_group, format_user_or_group_width): ID arg is now uintmax_t, not unsigned long, since uid_t and gid_t values might exceed ULONG_MAX. (format_user_or_group_width): Use snprintf with NULL instead of sprintf with a discarded buffer. This avoids a stack buffer, and so should be safer. --- src/ls.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/ls.c b/src/ls.c index efb87e405..e442118ec 100644 --- a/src/ls.c +++ b/src/ls.c @@ -971,7 +971,7 @@ enum { MIN_COLUMN_WIDTH =3D 3 }; for each byte of output generated by this program so that the beginni= ng and ending indices (in that output) of every file name can be recorde= d and later output themselves. */ -static size_t dired_pos; +static off_t dired_pos; =20 static void dired_outbyte (char c) @@ -1076,10 +1076,13 @@ dired_dump_obstack (char const *prefix, struct ob= stack *os) n_pos =3D obstack_object_size (os) / sizeof (dired_pos); if (n_pos > 0) { - size_t *pos =3D (size_t *) obstack_finish (os); + off_t *pos =3D obstack_finish (os); fputs (prefix, stdout); for (size_t i =3D 0; i < n_pos; i++) - printf (" %lu", (unsigned long int) pos[i]); + { + intmax_t p =3D pos[i]; + printf (" %"PRIdMAX, p); + } putchar ('\n'); } } @@ -4187,7 +4190,7 @@ long_time_expected_width (void) print width of WIDTH columns. */ =20 static void -format_user_or_group (char const *name, unsigned long int id, int width)= +format_user_or_group (char const *name, uintmax_t id, int width) { if (name) { @@ -4200,7 +4203,7 @@ format_user_or_group (char const *name, unsigned lo= ng int id, int width) while (pad--); } else - dired_pos +=3D printf ("%*lu ", width, id); + dired_pos +=3D printf ("%*"PRIuMAX" ", width, id); } =20 /* Print the name or id of the user with id U, using a print width of @@ -4225,7 +4228,7 @@ format_group (gid_t g, int width, bool stat_ok) /* Return the number of columns that format_user_or_group will print. *= / =20 static int -format_user_or_group_width (char const *name, unsigned long int id) +format_user_or_group_width (char const *name, uintmax_t id) { if (name) { @@ -4233,10 +4236,7 @@ format_user_or_group_width (char const *name, unsi= gned long int id) return MAX (0, len); } else - { - char buf[INT_BUFSIZE_BOUND (id)]; - return sprintf (buf, "%lu", id); - } + return snprintf (NULL, 0, "%"PRIuMAX, id); } =20 /* Return the number of columns that format_user will print. */ --=20 2.30.2 --------------495408A2CFF03BB9F0482094 Content-Type: text/x-patch; charset=UTF-8; name="0007-ls-add-null-option-Bug-49716.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0007-ls-add-null-option-Bug-49716.patch" =46rom 7d44ac224c93940d1a708442c1edf1a927be7057 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 25 Jul 2021 21:24:02 -0700 Subject: [PATCH 7/7] ls: add --null option (Bug#49716) * NEWS, doc/coreutils.texi (General output formatting): * src/ls.c (usage): Document this. * src/ls.c (NULL_OPTION): New constant. (long_options): Add --null. (eolbyte): New static var. (dired_dump_obstack, main, print_dir, print_current_files) (print_many_per_line, print_horizontal, print_with_separator): Output eolbyte instead of '\n'. (decode_switches): Decode --null. * tests/ls/null-option.sh: New file. * tests/local.mk (all_tests): Add it. --- NEWS | 3 +++ doc/coreutils.texi | 4 ++++ src/ls.c | 39 +++++++++++++++++++++++++-------------- tests/local.mk | 1 + tests/ls/null-option.sh | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 66 insertions(+), 14 deletions(-) create mode 100755 tests/ls/null-option.sh diff --git a/NEWS b/NEWS index 5a1a98ace..8de0c31bd 100644 --- a/NEWS +++ b/NEWS @@ -83,6 +83,9 @@ GNU coreutils NEWS -= *- outline -*- ls now accepts the --sort=3Dwidth option, to sort by file name width. This is useful to more compactly organize the default vertical column = output. =20 + ls now accepts the --null option, to terminate each output line with + NUL instead of newline. + nl --line-increment can now take a negative number to decrement the co= unt. =20 stat supports more formats for representing decomposed device numbers.= diff --git a/doc/coreutils.texi b/doc/coreutils.texi index ea040458e..a7e5ecb92 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -8137,6 +8137,10 @@ option. It does not affect the file size written = by @option{-l}. List files horizontally, with as many as will fit on each line, separated by @samp{, } (a comma and a space). =20 +@item --null +@opindex --null +@outputNUL + @item -p @itemx --indicator-style=3Dslash @opindex -p diff --git a/src/ls.c b/src/ls.c index e442118ec..61759fde9 100644 --- a/src/ls.c +++ b/src/ls.c @@ -838,6 +838,7 @@ enum HIDE_OPTION, HYPERLINK_OPTION, INDICATOR_STYLE_OPTION, + NULL_OPTION, QUOTING_STYLE_OPTION, SHOW_CONTROL_CHARS_OPTION, SI_OPTION, @@ -858,6 +859,7 @@ static struct option const long_options[] =3D {"human-readable", no_argument, NULL, 'h'}, {"inode", no_argument, NULL, 'i'}, {"kibibytes", no_argument, NULL, 'k'}, + {"null", no_argument, NULL, NULL_OPTION}, {"numeric-uid-gid", no_argument, NULL, 'n'}, {"no-group", no_argument, NULL, 'G'}, {"hide-control-chars", no_argument, NULL, 'q'}, @@ -1065,6 +1067,8 @@ assert_matching_dev_ino (char const *name, struct d= ev_ino di) assert (sb.st_ino =3D=3D di.st_ino); } =20 +static char eolbyte =3D '\n'; + /* Write to standard output PREFIX, followed by the quoting style and a space-separated list of the integers stored in OS all on one line. = */ =20 @@ -1083,7 +1087,7 @@ dired_dump_obstack (char const *prefix, struct obst= ack *os) intmax_t p =3D pos[i]; printf (" %"PRIdMAX, p); } - putchar ('\n'); + putchar (eolbyte); } } =20 @@ -1764,7 +1768,7 @@ main (int argc, char **argv) { print_current_files (); if (pending_dirs) - dired_outbyte ('\n'); + dired_outbyte (eolbyte); } else if (n_files <=3D 1 && pending_dirs && pending_dirs->next =3D=3D 0= ) print_dir_name =3D false; @@ -1832,8 +1836,9 @@ main (int argc, char **argv) /* No need to free these since we're about to exit. */ dired_dump_obstack ("//DIRED//", &dired_obstack); dired_dump_obstack ("//SUBDIRED//", &subdired_obstack); - printf ("//DIRED-OPTIONS// --quoting-style=3D%s\n", - quoting_style_args[get_quoting_style (filename_quoting_opt= ions)]); + printf ("//DIRED-OPTIONS// --quoting-style=3D%s%c", + quoting_style_args[get_quoting_style (filename_quoting_opt= ions)], + eolbyte); } =20 if (LOOP_DETECT) @@ -2265,6 +2270,10 @@ decode_switches (int argc, char **argv) indicator_style_types); break; =20 + case NULL_OPTION: + eolbyte =3D 0; + break; + case QUOTING_STYLE_OPTION: set_quoting_style (NULL, XARGMATCH ("--quoting-style", optarg, @@ -2966,7 +2975,7 @@ print_dir (char const *name, char const *realname, = bool command_line_arg) if (recursive || print_dir_name) { if (!first) - dired_outbyte ('\n'); + dired_outbyte (eolbyte); first =3D false; dired_indent (); =20 @@ -2983,7 +2992,8 @@ print_dir (char const *name, char const *realname, = bool command_line_arg) =20 free (absolute_name); =20 - dired_outstring (":\n"); + dired_outbyte (':'); + dired_outbyte (eolbyte); } =20 /* Read the directory entries, and insert the subfiles into the 'cwd_f= ile' @@ -3073,7 +3083,7 @@ print_dir (char const *name, char const *realname, = bool command_line_arg) ST_NBLOCKSIZE, output_block_size); char *pend =3D p + strlen (p); *--p =3D ' '; - *pend++ =3D '\n'; + *pend++ =3D eolbyte; dired_indent (); dired_outstring (_("total")); dired_outbuf (p, pend - p); @@ -4103,7 +4113,7 @@ print_current_files (void) for (i =3D 0; i < cwd_n_used; i++) { print_file_name_and_frills (sorted_file[i], 0); - putchar ('\n'); + putchar (eolbyte); } break; =20 @@ -4130,7 +4140,7 @@ print_current_files (void) { set_normal_color (); print_long_format (sorted_file[i]); - dired_outbyte ('\n'); + dired_outbyte (eolbyte); } break; } @@ -5121,7 +5131,7 @@ print_many_per_line (void) indent (pos + name_length, pos + max_name_length); pos +=3D max_name_length; } - putchar ('\n'); + putchar (eolbyte); } } =20 @@ -5146,7 +5156,7 @@ print_horizontal (void) =20 if (col =3D=3D 0) { - putchar ('\n'); + putchar (eolbyte); pos =3D 0; } else @@ -5161,7 +5171,7 @@ print_horizontal (void) name_length =3D length_of_file_name_and_frills (f); max_name_length =3D line_fmt->col_arr[col]; } - putchar ('\n'); + putchar (eolbyte); } =20 /* Output name + SEP + ' '. */ @@ -5191,7 +5201,7 @@ print_with_separator (char sep) else { pos =3D 0; - separator =3D '\n'; + separator =3D eolbyte; } =20 putchar (sep); @@ -5201,7 +5211,7 @@ print_with_separator (char sep) print_file_name_and_frills (f, pos); pos +=3D len; } - putchar ('\n'); + putchar (eolbyte); } =20 /* Assuming cursor is at position FROM, indent up to position TO. @@ -5473,6 +5483,7 @@ Sort entries alphabetically if none of -cftuvSUX no= r --sort is specified.\n\ \n\ "), stdout); fputs (_("\ + --null end each output line with NUL, not newline\= n\ -n, --numeric-uid-gid like -l, but list numeric user and group ID= s\n\ -N, --literal print entry names without quoting\n\ -o like -l, but do not list group information\= n\ diff --git a/tests/local.mk b/tests/local.mk index 81be52a34..441edc1be 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -612,6 +612,7 @@ all_tests =3D \ tests/ls/infloop.sh \ tests/ls/inode.sh \ tests/ls/m-option.sh \ + tests/ls/null-option.sh \ tests/ls/w-option.sh \ tests/ls/multihardlink.sh \ tests/ls/no-arg.sh \ diff --git a/tests/ls/null-option.sh b/tests/ls/null-option.sh new file mode 100755 index 000000000..fbf64e16d --- /dev/null +++ b/tests/ls/null-option.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# Verify behavior of ls --null. + +# Copyright 2021 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see .= + +. "${srcdir=3D.}/tests/init.sh"; path_prepend_ ./src +print_ver_ ls + +mkdir dir && touch dir/a dir/b dir/cc || framework_failure_ + +LC_ALL=3DC ls --null dir >out || fail=3D1 +tr '\n' '\0' <exp +a +b +cc +EOF + +compare exp out || fail=3D1 + +Exit $fail --=20 2.30.2 --------------495408A2CFF03BB9F0482094-- From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 26 11:00:59 2021 Received: (at 49716) by debbugs.gnu.org; 26 Jul 2021 15:00:59 +0000 Received: from localhost ([127.0.0.1]:51315 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m826E-0005jN-MV for submit@debbugs.gnu.org; Mon, 26 Jul 2021 11:00:58 -0400 Received: from mail-wr1-f53.google.com ([209.85.221.53]:44887) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m826A-0005j2-3A for 49716@debbugs.gnu.org; Mon, 26 Jul 2021 11:00:56 -0400 Received: by mail-wr1-f53.google.com with SMTP id z7so11405409wrn.11 for <49716@debbugs.gnu.org>; Mon, 26 Jul 2021 08:00:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=c8cSt9L6FGKB2ol6+k6zF87XZEt9y41IFehqyurNY48=; b=MEhIXl+VNCcRWBsW2qQthcnrZCJyURFklvNLo5QvphOc+tmCigxrEYXvJpdzX4uSI/ +FKuo0X7ThftjJSRqVQpFCbK7CL8ziRHo5WSLf4WTV/vWLIEaQLXG5ey3F8FWORyjqX8 rXCQKLH9Oj+/mr4Hk97xviy3bd3DPgH0MpuWlBvYHhDtAiyB6U7nGCEcym49ans7fEyt lJx1em21wxnwosGBO/NuTgQtmtzBQnIikCDDRkBwVjCHHQjHazQRugty/OPnJ4HvYJZu VUj536Adp0mjEP951D8wkR2KYngc/KVObwEkFxPSDN+oe3ZDBVHn3qF4oS+g84uMIjKs /aOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=c8cSt9L6FGKB2ol6+k6zF87XZEt9y41IFehqyurNY48=; b=NBUBOtUkITEWcfRn/6IwChPewvzefecKJEwRLlkyDuLzHloDW2O9Zkm7MetWLqhqyX Dbu7hiZDhv+tcJsCo/8rr8ZTsN4aI/N6KwoMHruYu0jldJdZ47qUUXH0Q4+szbSbJTGp xpbgOZKItr19NP5mXYWidK5WgIeAPI+nMzERHNu0lKCK5Uo1nmrkYmcdCcKFJPIvYs/T QaXosoQNcg/6dj3JQ6tBg8XuYkTRR69oi3PbzfBIXxv2Dt5FfSiojQg/XePOS23iUJqm MkgmQq+tTHoFCL8qkj1Ul7V3b+3kv8dO0hfNthG3vqum0VflqQ2ChyHZygkrWN2zeSke gVlA== X-Gm-Message-State: AOAM530SgQpgQMJ+SWWt2kXvBnThDel2UwJeyqeprDBb7mbOFtmfaldX RiyctsOFzkgf44K6hXWYZdbAn1UyxAxrLg== X-Google-Smtp-Source: ABdhPJyqexAO11kBdYNYdWVg8cJOj/NBgQ6nguSKCmWcPRUWFLNpx/w3bFJWQovbp3j5SNXnWLPV0Q== X-Received: by 2002:adf:d4c5:: with SMTP id w5mr13318099wrk.381.1627311647854; Mon, 26 Jul 2021 08:00:47 -0700 (PDT) Received: from localhost.localdomain (86-42-15-3-dynamic.agg2.lod.rsl-rtd.eircom.net. [86.42.15.3]) by smtp.googlemail.com with UTF8SMTPSA id f2sm27776wrq.69.2021.07.26.08.00.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Jul 2021 08:00:47 -0700 (PDT) Subject: Re: bug#49716: no -print0 for ls? To: Paul Eggert References: <20210724070324.aarmrjo2zn6j7d6z@shells.gnugeneration.com> <368bf886-37a5-961a-9c66-0d818db205bf@draigBrady.com> <20210724163459.dtlctjmkgfllz4cq@shells.gnugeneration.com> <20210724174807.fb2ue4b53q4ia2k4@shells.gnugeneration.com> <73d6ac6a-f70f-295a-2cab-9cd36e827ca4@cs.ucla.edu> <1ccd5c7a-afb8-706d-80aa-9a00128f2674@cs.ucla.edu> <37d3f590-50ee-4c03-df0d-72f3d72a346c@cs.ucla.edu> From: =?UTF-8?Q?P=c3=a1draig_Brady?= Message-ID: Date: Mon, 26 Jul 2021 16:00:46 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Thunderbird/84.0 MIME-Version: 1.0 In-Reply-To: <37d3f590-50ee-4c03-df0d-72f3d72a346c@cs.ucla.edu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Score: 0.4 (/) X-Debbugs-Envelope-To: 49716 Cc: Vito Caputo , 49716@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.6 (/) On 26/07/2021 09:05, Paul Eggert wrote: > On 7/25/21 10:10 AM, Pádraig Brady wrote: >> Right we should be especially careful of short options with ls. >> A long only option should suffice > > OK, I installed the attached to implement 'ls --null'. (The last patch > is the actual change; the other patches are cleanups.) This addresses > the problem raised in the bug report. > > Is there any pattern as to why some coreutils programs have a --null > option and others have a --zero option? The two options seem to mean the > same thing. Should we work toward standardizing on one spelling or the > other (of course maintaining backward compatibility). The patch set looks good thanks. Note we were consolidating on --zero rather than --null $ grep -l -F -- --zero src/*.c | fmt src/basename.c src/comm.c src/cut.c src/dirname.c src/head.c src/id.c src/join.c src/md5sum.c src/numfmt.c src/paste.c src/readlink.c src/realpath.c src/shred.c src/shuf.c src/sort.c src/tail.c src/uniq.c $ grep -l -F -- --null src/*.c | fmt src/du.c src/env.c src/ls.c src/printenv.c So I'd have a slight preference for --zero. Also what about having --zero imply: --quoting-style=literal --show-control-chars --format=single-column That seems like a fine shortcut given that would be correct in the vast majority of cases, and that the need for the above may not be obvious to users. Also a small point; should --dired disable --null as it may then be non parseable? thanks, Pádraig. p.s. I installed a trivial patch to avoid syntax-check issues From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 26 15:52:55 2021 Received: (at 49716) by debbugs.gnu.org; 26 Jul 2021 19:52:55 +0000 Received: from localhost ([127.0.0.1]:51547 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m86el-0006ch-JG for submit@debbugs.gnu.org; Mon, 26 Jul 2021 15:52:55 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:50041) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m86ef-0006cQ-Ud for 49716@debbugs.gnu.org; Mon, 26 Jul 2021 15:52:54 -0400 Received: from [192.168.101.10] ([91.1.211.171]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MryOx-1lKUjx1sOL-00nxHD; Mon, 26 Jul 2021 21:52:28 +0200 Subject: Re: bug#49716: no -print0 for ls? To: =?UTF-8?Q?P=c3=a1draig_Brady?= , Paul Eggert References: <20210724070324.aarmrjo2zn6j7d6z@shells.gnugeneration.com> <368bf886-37a5-961a-9c66-0d818db205bf@draigBrady.com> <20210724163459.dtlctjmkgfllz4cq@shells.gnugeneration.com> <20210724174807.fb2ue4b53q4ia2k4@shells.gnugeneration.com> <73d6ac6a-f70f-295a-2cab-9cd36e827ca4@cs.ucla.edu> <1ccd5c7a-afb8-706d-80aa-9a00128f2674@cs.ucla.edu> <37d3f590-50ee-4c03-df0d-72f3d72a346c@cs.ucla.edu> From: Bernhard Voelker Message-ID: <263c5cd9-b2a4-93fa-f7fd-2b89e789e71e@bernhard-voelker.de> Date: Mon, 26 Jul 2021 21:52:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:2zIuQsEaDIU8hk1elbQElbdHvKyGjsdBmnd1r0FXr741rtVXsg3 DghY4pUXZLosNkXdpWKJAQ6R/TKdu/8dOkXTZLOqcxjqjAsgtfH63UqktZ6VQKcAMtSqYZP Vyyjv1WxIeVJ+bu1VGCgzHyMGMX5dySxYA57/ncJF2bmhni+jH1u4iPb+mZromN11jiqKmu bGXm6PxovcRCdpBVJs6bw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:U5VLqCwSt1g=:IwmaVFcXBdBMzjOH5HFsqm nmWzL/dGNpyOi1H2r9mORsON8jONArxoB5cfK3+vXRUOtEaaZyscYSWouBjC1FKFyYy+NXZ0e HOp/zPbHic26LnMbqDTeUeVIQF1Yiq6k9u6dK3XJ7h3P1Ein+QB80VVpFfHnX2MYK53Wc5RwB 6aCb8Anf3ohtWWjkfD8vSouDWRG153pOiI19yIQrcWhIrfZBrJh7bRmIA/xFiXk6+DqfZhnG9 eNjFEtoLd5gMkVWLFhyxCn5Xlv67dGKslYsYi6CTKevNhBh0WipbS71e0I4hJnlghYVnbqKSA 1nwWISir2sW0LSjDHBQpJe3g3wbTpE81FgMT+aKZ+GGM3gXl1ecbAa6s1CZ1BnTWPpdi38vT2 /qPgHywb6KXE3gZ0MWynMN3jXMpp0JLtbzUVR4heKixWOYX0Xqg68OGrkRXDPtiB3kD8+L6oC 5KOL5Kbz+Sv6MAVeDQ+mTSthaIDQRcdjrQW46mUDEd13mn0wC7WU5MDsWM/3XDz4KJpQ2JW+h 6EEgL9hJS8stRGqZkLDmt7dPewClKYSe2PLGYsAr6WVUM24WBQ6PPnF3EHD9ANYqUf0jwOeCO dzqohyK3XRUOB+Ar/5IJ1kGCeIJyNrRHIc5GFWRbb8Tl+R+0GDIWCjmLQ7fJfuS8+zlq259bh 9BUTGCKHWIUljWysiTlHnc3S+A1EaHh3jk/UwVwmE6pyv4ObgaFTLSYXNbRgT3GCotcapesaH /Wg3domGzhJbc/s2zFFZYR/hetKrigEKtYdZYK4h+tJP3gkG0mr+EGfgZbuEYaSSUa/gok2lF tAGgvYsQtaVPVECofZp0rAMeQTkQ1HEpSu+Vhnb/LC/P5yYU1KBReVZRXYu/bzuhZBnqMCckp VPQG9KqPxfTprYW8nJJw== X-Spam-Score: -0.1 (/) X-Debbugs-Envelope-To: 49716 Cc: Vito Caputo , 49716@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.1 (-) On 7/26/21 5:00 PM, Pádraig Brady wrote: > The patch set looks good thanks. Wait - I see another reason why we didn't add it earlier: The --null option is not compatible with about half of the other options of ls(1); at least the actual output is more than questionable, and not usable in programmatic context. The -R option is the first one which obviously can't work as such. The following options don't work well with --null, because they output other, additional information or transform/escape the file names: -b, --escape print C-style escapes for nongraphic characters -C list entries by columns --color[=WHEN] colorize the output; WHEN can be 'always' (default if omitted), 'auto', or 'never'; more info below -F, --classify append indicator (one of */=>@|) to entries --file-type likewise, except do not append '*' --full-time like -l --time-style=full-iso -g like -l, but do not list owner --indicator-style=WORD append indicator with style WORD to entry names: none (default), slash (-p), file-type (--file-type), classify (-F) -i, --inode print the index number of each file -l use a long listing format -m fill width with a comma separated list of entries -n, --numeric-uid-gid like -l, but list numeric user and group IDs -o like -l, but do not list group information -p, --indicator-style=slash append / indicator to directories -q, --hide-control-chars print ? instead of nongraphic characters -Q, --quote-name enclose entry names in double quotes --quoting-style=WORD use quoting style WORD for entry names: literal, locale, shell, shell-always, shell-escape, shell-escape-always, c, escape (overrides QUOTING_STYLE environment variable) -R, --recursive list subdirectories recursively -s, --size print the allocated size of each file, in blocks -x list entries by lines instead of by columns -Z, --context print any security context of each file While the actual change is small - i.e., change the newline to a '\0' for the eolchar, I'm afraid that it will become quite hairy to discuss the actual problems of future users of that option when combining it with one of the above options. I really have some qualms with adding --null to ls(1). If this is about listing files in the current directory in a certain sort order for a processing purpose, then this would IMO warrant a new utility rather than blowing ls(1). Have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 26 16:02:41 2021 Received: (at 49716) by debbugs.gnu.org; 26 Jul 2021 20:02:41 +0000 Received: from localhost ([127.0.0.1]:51574 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m86oD-0006sf-2E for submit@debbugs.gnu.org; Mon, 26 Jul 2021 16:02:41 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:32834) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m86oB-0006sS-IE for 49716@debbugs.gnu.org; Mon, 26 Jul 2021 16:02:40 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 92A79160060; Mon, 26 Jul 2021 13:02:32 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id R6FwBt2rmgAS; Mon, 26 Jul 2021 13:02:31 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id DD1F71600E5; Mon, 26 Jul 2021 13:02:31 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id EotWX1JltxVb; Mon, 26 Jul 2021 13:02:31 -0700 (PDT) Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id B3CC1160060; Mon, 26 Jul 2021 13:02:31 -0700 (PDT) To: Bernhard Voelker , =?UTF-8?Q?P=c3=a1draig_Brady?= References: <20210724070324.aarmrjo2zn6j7d6z@shells.gnugeneration.com> <368bf886-37a5-961a-9c66-0d818db205bf@draigBrady.com> <20210724163459.dtlctjmkgfllz4cq@shells.gnugeneration.com> <20210724174807.fb2ue4b53q4ia2k4@shells.gnugeneration.com> <73d6ac6a-f70f-295a-2cab-9cd36e827ca4@cs.ucla.edu> <1ccd5c7a-afb8-706d-80aa-9a00128f2674@cs.ucla.edu> <37d3f590-50ee-4c03-df0d-72f3d72a346c@cs.ucla.edu> <263c5cd9-b2a4-93fa-f7fd-2b89e789e71e@bernhard-voelker.de> From: Paul Eggert Organization: UCLA Computer Science Department Subject: Re: bug#49716: no -print0 for ls? Message-ID: <0d0dcee3-26cd-dda1-0022-b2c8f949cbf0@cs.ucla.edu> Date: Mon, 26 Jul 2021 13:02:31 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <263c5cd9-b2a4-93fa-f7fd-2b89e789e71e@bernhard-voelker.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.4 (--) X-Debbugs-Envelope-To: 49716 Cc: Vito Caputo , 49716@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.4 (---) On 7/26/21 12:52 PM, Bernhard Voelker wrote: > The following options don't work well with --null, because they output = other, > additional information or transform/escape the file names: ... > -l use a long listing format I don't see a problem with -l, as --null can be a win with -l because=20 file names are more-reliably parsed in output from -l --null than they=20 are from plain -l. More generally, I don't see a problem with -F, --file-type, --full-time,=20 -g, --indicator-style, -i, -l, -n, -o, -p, -R, -s, or -Z. In all those=20 cases it can be a win to use --null so that file names are unambiguous=20 and easily parsed. I do see a problem for -b, -C, --color, -q, -Q, --quoting-style, -x.=20 P=C3=A1draig made a similar point. I'll look into this and into his other= points. > this > would IMO warrant a new utility rather than blowing ls(1). Oh I don't know, ls seems to be a natural home for "Do what 'ls' does,=20 except with NUL instead of newline." From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 27 21:14:57 2021 Received: (at 49716) by debbugs.gnu.org; 28 Jul 2021 01:14:57 +0000 Received: from localhost ([127.0.0.1]:54302 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m8Y9j-00047b-UH for submit@debbugs.gnu.org; Tue, 27 Jul 2021 21:14:57 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:49612) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m8Y9h-00047N-4a for 49716@debbugs.gnu.org; Tue, 27 Jul 2021 21:14:43 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 509151600AF; Tue, 27 Jul 2021 18:14:35 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id GIeXcI8BxIL7; Tue, 27 Jul 2021 18:14:32 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 123041600DB; Tue, 27 Jul 2021 18:14:32 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Q6jjV39jDvXW; Tue, 27 Jul 2021 18:14:31 -0700 (PDT) Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id C5AA71600AF; Tue, 27 Jul 2021 18:14:31 -0700 (PDT) Subject: Re: bug#49716: no -print0 for ls? To: =?UTF-8?Q?P=c3=a1draig_Brady?= References: <20210724070324.aarmrjo2zn6j7d6z@shells.gnugeneration.com> <368bf886-37a5-961a-9c66-0d818db205bf@draigBrady.com> <20210724163459.dtlctjmkgfllz4cq@shells.gnugeneration.com> <20210724174807.fb2ue4b53q4ia2k4@shells.gnugeneration.com> <73d6ac6a-f70f-295a-2cab-9cd36e827ca4@cs.ucla.edu> <1ccd5c7a-afb8-706d-80aa-9a00128f2674@cs.ucla.edu> <37d3f590-50ee-4c03-df0d-72f3d72a346c@cs.ucla.edu> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: <91f5dca6-1c8f-9bfa-a311-e30819e8230f@cs.ucla.edu> Date: Tue, 27 Jul 2021 18:14:31 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------01BBC1DA7F2EF2852F9E256C" Content-Language: en-US X-Spam-Score: -2.4 (--) X-Debbugs-Envelope-To: 49716 Cc: Vito Caputo , 49716@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.1 (-) This is a multi-part message in MIME format. --------------01BBC1DA7F2EF2852F9E256C Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable On 7/26/21 8:00 AM, P=C3=A1draig Brady wrote: > So I'd have a slight preference for --zero. >=20 > Also what about having --zero imply: > =C2=A0 --quoting-style=3Dliteral --show-control-chars --format=3Dsingl= e-column > That seems like a fine shortcut given that would be correct in the vast= =20 > majority of cases, > and that the need for the above may not be obvious to users. >=20 > Also a small point; should --dired disable --null as it may then be non= =20 > parseable? Thanks, all good suggestions. For --dired vs --zero I thought it better=20 simply to prohibit the combination since neither should be in 'ls' shell=20 aliases, and prohibiting means we can add it later if we like. I=20 installed the attached patches to do this (plus the other stuff I=20 mentioned in my reply to Berny). The first patch is a cleanup because I had a bit of trouble following=20 the forest of 'if's inside of ls.c's decode_switches function and I=20 thought it better to avoid unnecessary syscalls while I was at it. The second patch does the real work. --------------01BBC1DA7F2EF2852F9E256C Content-Type: text/x-patch; charset=UTF-8; name="0001-ls-compute-defaults-more-lazily.patch" Content-Disposition: attachment; filename="0001-ls-compute-defaults-more-lazily.patch" Content-Transfer-Encoding: quoted-printable >From 9e4a6101f239b8168144078edd04843dea4dc69f Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 27 Jul 2021 14:27:00 -0700 Subject: [PATCH 1/2] ls: compute defaults more lazily MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit * src/ls.c (enum time_type, enum sort_type, enum indicator_style) (enum Dereference_symlink, ignore_mode): Put =E2=80=98=3D 0=E2=80=99 after default values, since the code relies on static storage defaulting to zero. (enum sort_type): Reorder so that -1 can be used to represent unset. (main): Test print_with_color after parse_ls_color may have reset it. (decode_line_length): Return the line length instead of setting static storage. All uses changed. Treat line lengths exceeding PTRDIFF_MAX as infinite, to avoid pointer-subtraction glitches. (stdout_isatty): New function, to avoid calling isatty twice. (decode_switches): Calculate defaults more lazily, to avoid using syscalls or getenv during startup unless the results are more likely to be needed. Use -1 to indicate options that haven=E2=80=99t bee= n set on the command line yet. Move print_with_color test from here to =E2=80=98main=E2=80=99. Suppress bogus GCC warning. (getenv_quoting_style): Return the quoting style instead of setting static storage. (init_column_info): New arg MAX_COLS, to avoid recalculating it. Caller changed. --- src/ls.c | 395 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 200 insertions(+), 195 deletions(-) diff --git a/src/ls.c b/src/ls.c index 61759fde9..42333978e 100644 --- a/src/ls.c +++ b/src/ls.c @@ -304,7 +304,7 @@ static void queue_directory (char const *name, char c= onst *realname, static void sort_files (void); static void parse_ls_color (void); =20 -static void getenv_quoting_style (void); +static int getenv_quoting_style (void); =20 static size_t quote_name_width (char const *name, struct quoting_options const *options, @@ -463,7 +463,7 @@ ARGMATCH_VERIFY (time_style_args, time_style_types); =20 enum time_type { - time_mtime, /* default */ + time_mtime =3D 0, /* default */ time_ctime, /* -c */ time_atime, /* -u */ time_btime, /* birth time */ @@ -478,13 +478,13 @@ static enum time_type time_type; =20 enum sort_type { - sort_none =3D -1, /* -U */ - sort_name, /* default */ + sort_name =3D 0, /* default */ sort_extension, /* -X */ sort_width, sort_size, /* -S */ sort_version, /* -v */ - sort_time, /* -t */ + sort_time, /* -t; must be second to last */ + sort_none, /* -U; must be last */ sort_numtypes /* the number of elements of this enum */ }; =20 @@ -543,7 +543,7 @@ static bool dired; =20 enum indicator_style { - none, /* --indicator-style=3Dnone */ + none =3D 0, /* --indicator-style=3Dnone (default) */ slash, /* -p, --indicator-style=3Dslash */ file_type, /* --indicator-style=3Dfile-type */ classify /* -F, --indicator-style=3Dclassify */ @@ -585,7 +585,7 @@ enum when_type =20 enum Dereference_symlink { - DEREF_UNDEFINED =3D 1, + DEREF_UNDEFINED =3D 0, /* default */ DEREF_NEVER, DEREF_COMMAND_LINE_ARGUMENTS, /* -H */ DEREF_COMMAND_LINE_SYMLINK_TO_DIR, /* the default, in certain cases = */ @@ -683,7 +683,7 @@ static enum { /* Ignore files whose names start with '.', and files specified by --hide and --ignore. */ - IGNORE_DEFAULT, + IGNORE_DEFAULT =3D 0, =20 /* Ignore '.', '..', and files specified by --ignore. */ IGNORE_DOT_AND_DOTDOT, @@ -734,7 +734,7 @@ static size_t tabsize; static bool print_dir_name; =20 /* The line length to use for breaking lines in many-per-line format. - Can be set with -w. */ + Can be set with -w. If zero, there is no limit. */ =20 static size_t line_length; =20 @@ -1671,6 +1671,15 @@ main (int argc, char **argv) =20 /* Test print_with_color again, because the call to parse_ls_color may have just reset it -- e.g., if LS_COLORS is invalid. */ + + if (print_with_color) + { + /* Don't use TAB characters in output. Some terminal + emulators can't handle the combination of tabs and + color codes on the same line. */ + tabsize =3D 0; + } + if (directories_first) check_symlink_mode =3D true; else if (print_with_color) @@ -1850,31 +1859,41 @@ main (int argc, char **argv) return exit_status; } =20 -/* Set the line length to the value given by SPEC. Return true if - successful. 0 means no limit on line length. */ +/* Return the line length indicated by the value given by SPEC, or -1 + if unsuccessful. 0 means no limit on line length. */ =20 -static bool -set_line_length (char const *spec) +static ptrdiff_t +decode_line_length (char const *spec) { uintmax_t val; =20 - /* Treat too-large values as if they were SIZE_MAX, which is + /* Treat too-large values as if they were 0, which is effectively infinity. */ switch (xstrtoumax (spec, NULL, 0, &val, "")) { case LONGINT_OK: - line_length =3D MIN (val, SIZE_MAX); - return true; + return val <=3D MIN (PTRDIFF_MAX, SIZE_MAX) ? val : 0; =20 case LONGINT_OVERFLOW: - line_length =3D SIZE_MAX; - return true; + return 0; =20 default: - return false; + return -1; } } =20 +/* Return true if standard output is a tty, caching the result. */ + +static bool +stdout_isatty (void) +{ + static signed char out_tty =3D -1; + if (out_tty < 0) + out_tty =3D isatty (STDOUT_FILENO); + assume (out_tty =3D=3D 0 || out_tty =3D=3D 1); + return out_tty; +} + /* Set all the option flags according to the switches specified. Return the index of the first non-option argument. */ =20 @@ -1883,99 +1902,14 @@ decode_switches (int argc, char **argv) { char *time_style_option =3D NULL; =20 - bool sort_type_specified =3D false; + /* These variables are false or -1 unless a switch says otherwise. */ bool kibibytes_specified =3D false; - - qmark_funny_chars =3D false; - - /* initialize all switches to default settings */ - - switch (ls_mode) - { - case LS_MULTI_COL: - /* This is for the 'dir' program. */ - format =3D many_per_line; - set_quoting_style (NULL, escape_quoting_style); - break; - - case LS_LONG_FORMAT: - /* This is for the 'vdir' program. */ - format =3D long_format; - set_quoting_style (NULL, escape_quoting_style); - break; - - case LS_LS: - /* This is for the 'ls' program. */ - if (isatty (STDOUT_FILENO)) - { - format =3D many_per_line; - set_quoting_style (NULL, shell_escape_quoting_style); - /* See description of qmark_funny_chars, above. */ - qmark_funny_chars =3D true; - } - else - { - format =3D one_per_line; - qmark_funny_chars =3D false; - } - break; - - default: - abort (); - } - - time_type =3D time_mtime; - sort_type =3D sort_name; - sort_reverse =3D false; - numeric_ids =3D false; - print_block_size =3D false; - indicator_style =3D none; - print_inode =3D false; - dereference =3D DEREF_UNDEFINED; - recursive =3D false; - immediate_dirs =3D false; - ignore_mode =3D IGNORE_DEFAULT; - ignore_patterns =3D NULL; - hide_patterns =3D NULL; - print_scontext =3D false; - - getenv_quoting_style (); - - line_length =3D 80; - { - char const *p =3D getenv ("COLUMNS"); - if (p && *p && ! set_line_length (p)) - error (0, 0, - _("ignoring invalid width in environment variable COLUMNS: = %s"), - quote (p)); - } - -#ifdef TIOCGWINSZ - { - struct winsize ws; - - if (ioctl (STDOUT_FILENO, TIOCGWINSZ, &ws) !=3D -1 - && 0 < ws.ws_col && ws.ws_col =3D=3D (size_t) ws.ws_col) - line_length =3D ws.ws_col; - } -#endif - - { - char const *p =3D getenv ("TABSIZE"); - tabsize =3D 8; - if (p) - { - uintmax_t tmp; - if (xstrtoumax (p, NULL, 0, &tmp, "") =3D=3D LONGINT_OK - && tmp <=3D SIZE_MAX) - tabsize =3D tmp; - else - error (0, 0, - _("ignoring invalid tab size in environment variable TA= BSIZE:" - " %s"), - quote (p)); - } - } + int format_opt =3D -1; + int hide_control_chars_opt =3D -1; + int quoting_style_opt =3D -1; + int sort_opt =3D -1; + ptrdiff_t tabsize_opt =3D -1; + ptrdiff_t width_opt =3D -1; =20 while (true) { @@ -1993,7 +1927,7 @@ decode_switches (int argc, char **argv) break; =20 case 'b': - set_quoting_style (NULL, escape_quoting_style); + quoting_style_opt =3D escape_quoting_style; break; =20 case 'c': @@ -2007,11 +1941,10 @@ decode_switches (int argc, char **argv) case 'f': /* Same as enabling -a -U and disabling -l -s. */ ignore_mode =3D IGNORE_MINIMAL; - sort_type =3D sort_none; - sort_type_specified =3D true; + sort_opt =3D sort_none; /* disable -l */ - if (format =3D=3D long_format) - format =3D (isatty (STDOUT_FILENO) ? many_per_line : one_per= _line); + if (format_opt =3D=3D long_format) + format_opt =3D -1; print_block_size =3D false; /* disable -s */ print_with_color =3D false; /* disable --color */ print_hyperlink =3D false; /* disable --hyperlink */ @@ -2022,7 +1955,7 @@ decode_switches (int argc, char **argv) break; =20 case 'g': - format =3D long_format; + format_opt =3D long_format; print_owner =3D false; break; =20 @@ -2041,20 +1974,20 @@ decode_switches (int argc, char **argv) break; =20 case 'l': - format =3D long_format; + format_opt =3D long_format; break; =20 case 'm': - format =3D with_commas; + format_opt =3D with_commas; break; =20 case 'n': numeric_ids =3D true; - format =3D long_format; + format_opt =3D long_format; break; =20 case 'o': /* Just like -l, but don't display group info. */ - format =3D long_format; + format_opt =3D long_format; print_group =3D false; break; =20 @@ -2063,7 +1996,7 @@ decode_switches (int argc, char **argv) break; =20 case 'q': - qmark_funny_chars =3D true; + hide_control_chars_opt =3D true; break; =20 case 'r': @@ -2075,8 +2008,7 @@ decode_switches (int argc, char **argv) break; =20 case 't': - sort_type =3D sort_time; - sort_type_specified =3D true; + sort_opt =3D sort_time; break; =20 case 'u': @@ -2084,18 +2016,18 @@ decode_switches (int argc, char **argv) break; =20 case 'v': - sort_type =3D sort_version; - sort_type_specified =3D true; + sort_opt =3D sort_version; break; =20 case 'w': - if (! set_line_length (optarg)) + width_opt =3D decode_line_length (optarg); + if (width_opt < 0) die (LS_FAILURE, 0, "%s: %s", _("invalid line width"), quote (optarg)); break; =20 case 'x': - format =3D horizontal; + format_opt =3D horizontal; break; =20 case 'A': @@ -2108,7 +2040,7 @@ decode_switches (int argc, char **argv) break; =20 case 'C': - format =3D many_per_line; + format_opt =3D many_per_line; break; =20 case 'D': @@ -2125,8 +2057,7 @@ decode_switches (int argc, char **argv) --classify=3Dalways. */ i =3D when_always; =20 - if (i =3D=3D when_always - || (i =3D=3D when_if_tty && isatty (STDOUT_FILENO))) + if (i =3D=3D when_always || (i =3D=3D when_if_tty && stdout_= isatty ())) indicator_style =3D classify; break; } @@ -2152,11 +2083,11 @@ decode_switches (int argc, char **argv) break; =20 case 'N': - set_quoting_style (NULL, literal_quoting_style); + quoting_style_opt =3D literal_quoting_style; break; =20 case 'Q': - set_quoting_style (NULL, c_quoting_style); + quoting_style_opt =3D c_quoting_style; break; =20 case 'R': @@ -2164,29 +2095,26 @@ decode_switches (int argc, char **argv) break; =20 case 'S': - sort_type =3D sort_size; - sort_type_specified =3D true; + sort_opt =3D sort_size; break; =20 case 'T': - tabsize =3D xnumtoumax (optarg, 0, 0, SIZE_MAX, "", - _("invalid tab size"), LS_FAILURE); + tabsize_opt =3D xnumtoumax (optarg, 0, 0, MIN (PTRDIFF_MAX, SI= ZE_MAX), + "", _("invalid tab size"), LS_FAILUR= E); break; =20 case 'U': - sort_type =3D sort_none; - sort_type_specified =3D true; + sort_opt =3D sort_none; break; =20 case 'X': - sort_type =3D sort_extension; - sort_type_specified =3D true; + sort_opt =3D sort_extension; break; =20 case '1': /* -1 has no effect after -l. */ - if (format !=3D long_format) - format =3D one_per_line; + if (format_opt !=3D long_format) + format_opt =3D one_per_line; break; =20 case AUTHOR_OPTION: @@ -2203,8 +2131,7 @@ decode_switches (int argc, char **argv) break; =20 case SORT_OPTION: - sort_type =3D XARGMATCH ("--sort", optarg, sort_args, sort_typ= es); - sort_type_specified =3D true; + sort_opt =3D XARGMATCH ("--sort", optarg, sort_args, sort_type= s); break; =20 case GROUP_DIRECTORIES_FIRST_OPTION: @@ -2216,11 +2143,12 @@ decode_switches (int argc, char **argv) break; =20 case FORMAT_OPTION: - format =3D XARGMATCH ("--format", optarg, format_args, format_= types); + format_opt =3D XARGMATCH ("--format", optarg, format_args, + format_types); break; =20 case FULL_TIME_OPTION: - format =3D long_format; + format_opt =3D long_format; time_style_option =3D bad_cast ("full-iso"); break; =20 @@ -2235,16 +2163,7 @@ decode_switches (int argc, char **argv) i =3D when_always; =20 print_with_color =3D (i =3D=3D when_always - || (i =3D=3D when_if_tty - && isatty (STDOUT_FILENO))); - - if (print_with_color) - { - /* Don't use TAB characters in output. Some terminal - emulators can't handle the combination of tabs and - color codes on the same line. */ - tabsize =3D 0; - } + || (i =3D=3D when_if_tty && stdout_isatt= y ())); break; } =20 @@ -2259,8 +2178,7 @@ decode_switches (int argc, char **argv) i =3D when_always; =20 print_hyperlink =3D (i =3D=3D when_always - || (i =3D=3D when_if_tty - && isatty (STDOUT_FILENO))); + || (i =3D=3D when_if_tty && stdout_isatty= ())); break; } =20 @@ -2275,10 +2193,9 @@ decode_switches (int argc, char **argv) break; =20 case QUOTING_STYLE_OPTION: - set_quoting_style (NULL, - XARGMATCH ("--quoting-style", optarg, - quoting_style_args, - quoting_style_vals)); + quoting_style_opt =3D XARGMATCH ("--quoting-style", optarg, + quoting_style_args, + quoting_style_vals); break; =20 case TIME_STYLE_OPTION: @@ -2286,7 +2203,7 @@ decode_switches (int argc, char **argv) break; =20 case SHOW_CONTROL_CHARS_OPTION: - qmark_funny_chars =3D false; + hide_control_chars_opt =3D false; break; =20 case BLOCK_SIZE_OPTION: @@ -2336,19 +2253,106 @@ decode_switches (int argc, char **argv) } } =20 + + static signed char const default_format[] =3D + { + [LS_LS] =3D -1, + [LS_MULTI_COL] =3D many_per_line, + [LS_LONG_FORMAT] =3D long_format, + }; + int form =3D format_opt < 0 ? default_format[ls_mode] : format_opt; + format =3D form < 0 ? (stdout_isatty () ? many_per_line : one_per_line= ) : form; + + /* If the line length was not set by a switch but is needed to determi= ne + output, go to the work of obtaining it from the environment. */ + ptrdiff_t linelen =3D width_opt; + if (format =3D=3D many_per_line || format =3D=3D horizontal || format = =3D=3D with_commas + || print_with_color) + { +#ifdef TIOCGWINSZ + if (linelen < 0) + { + /* Suppress bogus warning re comparing ws.ws_col to big intege= r. */ +# if __GNUC_PREREQ (4, 6) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wtype-limits" +# endif + struct winsize ws; + if (stdout_isatty () + && 0 <=3D ioctl (STDOUT_FILENO, TIOCGWINSZ, &ws) + && 0 < ws.ws_col) + linelen =3D ws.ws_col <=3D MIN (PTRDIFF_MAX, SIZE_MAX) ? ws.= ws_col : 0; +# if __GNUC_PREREQ (4, 6) +# pragma GCC diagnostic pop +# endif + } +#endif + if (linelen < 0) + { + char const *p =3D getenv ("COLUMNS"); + if (p && *p) + { + linelen =3D decode_line_length (p); + if (linelen < 0) + error (0, 0, + _("ignoring invalid width" + " in environment variable COLUMNS: %s"), + quote (p)); + } + } + } + + line_length =3D linelen < 0 ? 80 : linelen; + /* Determine the max possible number of display columns. */ max_idx =3D line_length / MIN_COLUMN_WIDTH; /* Account for first display column not having a separator, or line_lengths shorter than MIN_COLUMN_WIDTH. */ max_idx +=3D line_length % MIN_COLUMN_WIDTH !=3D 0; =20 - enum quoting_style qs =3D get_quoting_style (NULL); - align_variable_outer_quotes =3D format !=3D with_commas - && format !=3D one_per_line - && (line_length || format =3D=3D long_fo= rmat) - && (qs =3D=3D shell_quoting_style - || qs =3D=3D shell_escape_quoting_st= yle - || qs =3D=3D c_maybe_quoting_style); + if (format =3D=3D many_per_line || format =3D=3D horizontal || format = =3D=3D with_commas) + { + if (0 <=3D tabsize_opt) + tabsize =3D tabsize_opt; + else + { + tabsize =3D 8; + char const *p =3D getenv ("TABSIZE"); + if (p) + { + uintmax_t tmp; + if (xstrtoumax (p, NULL, 0, &tmp, "") =3D=3D LONGINT_OK + && tmp <=3D SIZE_MAX) + tabsize =3D tmp; + else + error (0, 0, + _("ignoring invalid tab size" + " in environment variable TABSIZE: %s"), + quote (p)); + } + } + } + + qmark_funny_chars =3D (hide_control_chars_opt < 0 + ? ls_mode =3D=3D LS_LS && stdout_isatty () + : hide_control_chars_opt); + + int qs =3D quoting_style_opt; + if (qs < 0) + qs =3D getenv_quoting_style (); + if (qs < 0) + qs =3D (ls_mode =3D=3D LS_LS + ? (stdout_isatty () ? shell_escape_quoting_style : -1) + : escape_quoting_style); + if (0 <=3D qs) + set_quoting_style (NULL, qs); + qs =3D get_quoting_style (NULL); + align_variable_outer_quotes + =3D ((format =3D=3D long_format + || ((format =3D=3D many_per_line || format =3D=3D horizontal) &&= line_length)) + && (qs =3D=3D shell_quoting_style + || qs =3D=3D shell_escape_quoting_style + || qs =3D=3D c_maybe_quoting_style)); filename_quoting_options =3D clone_quoting_options (NULL); if (qs =3D=3D escape_quoting_style) set_char_quoting (filename_quoting_options, ' ', 1); @@ -2376,12 +2380,11 @@ decode_switches (int argc, char **argv) -lu means show atime and sort by name, -lut means show atime and so= rt by atime. */ =20 - if ((time_type =3D=3D time_ctime || time_type =3D=3D time_atime - || time_type =3D=3D time_btime) - && !sort_type_specified && format !=3D long_format) - { - sort_type =3D sort_time; - } + sort_type =3D (0 <=3D sort_opt ? sort_opt + : (format !=3D long_format + && (time_type =3D=3D time_ctime || time_type =3D=3D ti= me_atime + || time_type =3D=3D time_btime)) + ? sort_time : sort_name); =20 if (format =3D=3D long_format) { @@ -2856,23 +2859,25 @@ parse_ls_color (void) color_symlink_as_referent =3D true; } =20 -/* Set the quoting style default if the environment variable - QUOTING_STYLE is set. */ +/* Return the quoting style specified by the environment variable + QUOTING_STYLE if set and valid, -1 otherwise. */ =20 -static void +static int getenv_quoting_style (void) { char const *q_style =3D getenv ("QUOTING_STYLE"); - if (q_style) + if (!q_style) + return -1; + int i =3D ARGMATCH (q_style, quoting_style_args, quoting_style_vals); + if (i < 0) { - int i =3D ARGMATCH (q_style, quoting_style_args, quoting_style_val= s); - if (0 <=3D i) - set_quoting_style (NULL, quoting_style_vals[i]); - else - error (0, 0, - _("ignoring invalid value of environment variable QUOTING_STYLE: = %s"), - quote (q_style)); + error (0, 0, + _("ignoring invalid value" + " of environment variable QUOTING_STYLE: %s"), + quote (q_style)); + return -1; } + return quoting_style_vals[i]; } =20 /* Set the exit status to report a failure. If SERIOUS, it is a @@ -4022,14 +4027,15 @@ static qsortFunc const sort_functions[][2][2][2] = =3D =20 /* The number of sort keys is calculated as the sum of the number of elements in the sort_type enum (i.e., sort_numtypes) - the number of elements in the time_type enum (i.e., time_numtypes) = - 1 + -2 because neither sort_time nor sort_none use entries themselves + the number of elements in the time_type enum (i.e., time_numtypes) This is because when sort_type=3D=3Dsort_time, we have up to time_numtypes possible sort keys. =20 This line verifies at compile-time that the array of sort functions h= as been initialized for all possible sort keys. */ verify (ARRAY_CARDINALITY (sort_functions) - =3D=3D sort_numtypes + time_numtypes - 1 ); + =3D=3D sort_numtypes - 2 + time_numtypes); =20 /* Set up SORTED_FILE to point to the in-use entries in CWD_FILE, in ord= er. */ =20 @@ -5263,10 +5269,9 @@ attach (char *dest, char const *dirname, char cons= t *name) narrowest possible columns. */ =20 static void -init_column_info (void) +init_column_info (size_t max_cols) { size_t i; - size_t max_cols =3D MIN (max_idx, cwd_n_used); =20 /* Currently allocated columns in column_info. */ static size_t column_info_alloc; @@ -5276,7 +5281,7 @@ init_column_info (void) size_t new_column_info_alloc; size_t *p; =20 - if (max_cols < max_idx / 2) + if (!max_idx || max_cols < max_idx / 2) { /* The number of columns is far less than the display width allows. Grow the allocation, but only so that it's @@ -5339,9 +5344,9 @@ calculate_columns (bool by_columns) /* Normally the maximum number of columns is determined by the screen width. But if few files are available this might limit it as well. */ - size_t max_cols =3D MIN (max_idx, cwd_n_used); + size_t max_cols =3D 0 < max_idx && max_idx < cwd_n_used ? max_idx : cw= d_n_used; =20 - init_column_info (); + init_column_info (max_cols); =20 /* Compute the maximum number of possible columns. */ for (filesno =3D 0; filesno < cwd_n_used; ++filesno) --=20 2.30.2 --------------01BBC1DA7F2EF2852F9E256C Content-Type: text/x-patch; charset=UTF-8; name="0002-ls-rename-null-to-zero-Bug-49716.patch" Content-Disposition: attachment; filename="0002-ls-rename-null-to-zero-Bug-49716.patch" Content-Transfer-Encoding: quoted-printable >From c75779cac3abec6e6072c0ac77dced85d1c44370 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 27 Jul 2021 17:34:43 -0700 Subject: [PATCH 2/2] ls: rename --null to --zero (Bug#49716) MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit * NEWS, doc/coreutils.texi (General output formatting): * src/ls.c (usage): Document this. * src/ls.c (ZERO_OPTION): Rename from NULL_OPTION. All uses changed. (long_options): Rename --null to --zero. (dired_dump_obstack, main, print_dir): Use '\n' instead of eolbyte where eolbyte must equal '\n'. (decode_switches): Decode --zero instead of --null. --zero also implies -1, -N, --color=3Dnone, --show-control-chars. Use easier-to-decipher code to set =E2=80=98format=E2=80=99 and =E2=80=98= dired=E2=80=99. Reject attempts to combine --dired and --zero. * tests/local.mk: Adjust to test script renaming. * tests/ls/zero-option.sh: Rename from tests/ls/null-option.sh, and test --zero instead of --null. --- NEWS | 2 +- doc/coreutils.texi | 10 +++- src/ls.c | 57 +++++++++++---------- tests/local.mk | 4 +- tests/ls/{null-option.sh =3D> zero-option.sh} | 4 +- 5 files changed, 42 insertions(+), 35 deletions(-) rename tests/ls/{null-option.sh =3D> zero-option.sh} (92%) diff --git a/NEWS b/NEWS index 8de0c31bd..49ee083e4 100644 --- a/NEWS +++ b/NEWS @@ -83,7 +83,7 @@ GNU coreutils NEWS -= *- outline -*- ls now accepts the --sort=3Dwidth option, to sort by file name width. This is useful to more compactly organize the default vertical column = output. =20 - ls now accepts the --null option, to terminate each output line with + ls now accepts the --zero option, to terminate each output line with NUL instead of newline. =20 nl --line-increment can now take a negative number to decrement the co= unt. diff --git a/doc/coreutils.texi b/doc/coreutils.texi index a7e5ecb92..2d2770864 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -8137,8 +8137,14 @@ option. It does not affect the file size written = by @option{-l}. List files horizontally, with as many as will fit on each line, separated by @samp{, } (a comma and a space). =20 -@item --null -@opindex --null +@item --zero +@opindex --zero +This option is incompatible with the @option{-D} or @option{--dired} opt= ion. +This option also implies the options +@option{--show-control-chars}, +@option{-1} or @option{--format=3Dsingle-column}, +@option{--color=3Dnone}, and +@option{-N} or @option{--quoting-style=3Dliteral}. @outputNUL =20 @item -p diff --git a/src/ls.c b/src/ls.c index 42333978e..7ea956227 100644 --- a/src/ls.c +++ b/src/ls.c @@ -838,13 +838,13 @@ enum HIDE_OPTION, HYPERLINK_OPTION, INDICATOR_STYLE_OPTION, - NULL_OPTION, QUOTING_STYLE_OPTION, SHOW_CONTROL_CHARS_OPTION, SI_OPTION, SORT_OPTION, TIME_OPTION, - TIME_STYLE_OPTION + TIME_STYLE_OPTION, + ZERO_OPTION, }; =20 static struct option const long_options[] =3D @@ -859,7 +859,6 @@ static struct option const long_options[] =3D {"human-readable", no_argument, NULL, 'h'}, {"inode", no_argument, NULL, 'i'}, {"kibibytes", no_argument, NULL, 'k'}, - {"null", no_argument, NULL, NULL_OPTION}, {"numeric-uid-gid", no_argument, NULL, 'n'}, {"no-group", no_argument, NULL, 'G'}, {"hide-control-chars", no_argument, NULL, 'q'}, @@ -888,6 +887,7 @@ static struct option const long_options[] =3D {"tabsize", required_argument, NULL, 'T'}, {"time", required_argument, NULL, TIME_OPTION}, {"time-style", required_argument, NULL, TIME_STYLE_OPTION}, + {"zero", no_argument, NULL, ZERO_OPTION}, {"color", optional_argument, NULL, COLOR_OPTION}, {"hyperlink", optional_argument, NULL, HYPERLINK_OPTION}, {"block-size", required_argument, NULL, BLOCK_SIZE_OPTION}, @@ -1087,7 +1087,7 @@ dired_dump_obstack (char const *prefix, struct obst= ack *os) intmax_t p =3D pos[i]; printf (" %"PRIdMAX, p); } - putchar (eolbyte); + putchar ('\n'); } } =20 @@ -1777,7 +1777,7 @@ main (int argc, char **argv) { print_current_files (); if (pending_dirs) - dired_outbyte (eolbyte); + dired_outbyte ('\n'); } else if (n_files <=3D 1 && pending_dirs && pending_dirs->next =3D=3D 0= ) print_dir_name =3D false; @@ -1845,9 +1845,8 @@ main (int argc, char **argv) /* No need to free these since we're about to exit. */ dired_dump_obstack ("//DIRED//", &dired_obstack); dired_dump_obstack ("//SUBDIRED//", &subdired_obstack); - printf ("//DIRED-OPTIONS// --quoting-style=3D%s%c", - quoting_style_args[get_quoting_style (filename_quoting_opt= ions)], - eolbyte); + printf ("//DIRED-OPTIONS// --quoting-style=3D%s\n", + quoting_style_args[get_quoting_style (filename_quoting_opt= ions)]); } =20 if (LOOP_DETECT) @@ -2188,10 +2187,6 @@ decode_switches (int argc, char **argv) indicator_style_types); break; =20 - case NULL_OPTION: - eolbyte =3D 0; - break; - case QUOTING_STYLE_OPTION: quoting_style_opt =3D XARGMATCH ("--quoting-style", optarg, quoting_style_args, @@ -2227,6 +2222,15 @@ decode_switches (int argc, char **argv) print_scontext =3D true; break; =20 + case ZERO_OPTION: + eolbyte =3D 0; + hide_control_chars_opt =3D false; + if (format_opt !=3D long_format) + format_opt =3D one_per_line; + print_with_color =3D false; + quoting_style_opt =3D literal_quoting_style; + break; + case_GETOPT_HELP_CHAR; =20 case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); @@ -2253,15 +2257,11 @@ decode_switches (int argc, char **argv) } } =20 - - static signed char const default_format[] =3D - { - [LS_LS] =3D -1, - [LS_MULTI_COL] =3D many_per_line, - [LS_LONG_FORMAT] =3D long_format, - }; - int form =3D format_opt < 0 ? default_format[ls_mode] : format_opt; - format =3D form < 0 ? (stdout_isatty () ? many_per_line : one_per_line= ) : form; + format =3D (0 <=3D format_opt ? format_opt + : ls_mode =3D=3D LS_LS ? (stdout_isatty () + ? many_per_line : one_per_line) + : ls_mode =3D=3D LS_MULTI_COL ? many_per_line + : /* ls_mode =3D=3D LS_LONG_FORMAT */ long_format); =20 /* If the line length was not set by a switch but is needed to determi= ne output, go to the work of obtaining it from the environment. */ @@ -2366,11 +2366,13 @@ decode_switches (int argc, char **argv) dirname_quoting_options =3D clone_quoting_options (NULL); set_char_quoting (dirname_quoting_options, ':', 1); =20 - /* --dired is meaningful only with --format=3Dlong (-l). + /* --dired is meaningful only with --format=3Dlong (-l) and sans --hyp= erlink. Otherwise, ignore it. FIXME: warn about this? Alternatively, make --dired imply --format=3Dlong? */ - if (dired && (format !=3D long_format || print_hyperlink)) - dired =3D false; + dired &=3D (format =3D=3D long_format) & !print_hyperlink; + + if (eolbyte < dired) + die (LS_FAILURE, 0, _("--dired and --zero are incompatible")); =20 /* If -c or -u is specified and not -l (or any other option that impli= es -l), and no sort-type was specified, then sort by the ctime (-c) or atim= e (-u). @@ -2980,7 +2982,7 @@ print_dir (char const *name, char const *realname, = bool command_line_arg) if (recursive || print_dir_name) { if (!first) - dired_outbyte (eolbyte); + dired_outbyte ('\n'); first =3D false; dired_indent (); =20 @@ -2997,8 +2999,7 @@ print_dir (char const *name, char const *realname, = bool command_line_arg) =20 free (absolute_name); =20 - dired_outbyte (':'); - dired_outbyte (eolbyte); + dired_outstring (":\n"); } =20 /* Read the directory entries, and insert the subfiles into the 'cwd_f= ile' @@ -5488,7 +5489,6 @@ Sort entries alphabetically if none of -cftuvSUX no= r --sort is specified.\n\ \n\ "), stdout); fputs (_("\ - --null end each output line with NUL, not newline\= n\ -n, --numeric-uid-gid like -l, but list numeric user and group ID= s\n\ -N, --literal print entry names without quoting\n\ -o like -l, but do not list group information\= n\ @@ -5542,6 +5542,7 @@ Sort entries alphabetically if none of -cftuvSUX no= r --sort is specified.\n\ -x list entries by lines instead of by columns= \n\ -X sort alphabetically by entry extension\n\ -Z, --context print any security context of each file\n\ + --zero end each output line with NUL, not newline\= n\ -1 list one file per line. Avoid '\\n' with -= q or -b\ \n\ "), stdout); diff --git a/tests/local.mk b/tests/local.mk index 441edc1be..4a08147df 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -609,10 +609,10 @@ all_tests =3D \ tests/ls/getxattr-speedup.sh \ tests/ls/group-dirs.sh \ tests/ls/hex-option.sh \ + tests/ls/hyperlink.sh \ tests/ls/infloop.sh \ tests/ls/inode.sh \ tests/ls/m-option.sh \ - tests/ls/null-option.sh \ tests/ls/w-option.sh \ tests/ls/multihardlink.sh \ tests/ls/no-arg.sh \ @@ -635,7 +635,7 @@ all_tests =3D \ tests/ls/time-style-diag.sh \ tests/ls/sort-width-option.sh \ tests/ls/x-option.sh \ - tests/ls/hyperlink.sh \ + tests/ls/zero-option.sh \ tests/mkdir/p-1.sh \ tests/mkdir/p-2.sh \ tests/mkdir/p-3.sh \ diff --git a/tests/ls/null-option.sh b/tests/ls/zero-option.sh similarity index 92% rename from tests/ls/null-option.sh rename to tests/ls/zero-option.sh index fbf64e16d..a6883917f 100755 --- a/tests/ls/null-option.sh +++ b/tests/ls/zero-option.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Verify behavior of ls --null. +# Verify behavior of ls --zero. =20 # Copyright 2021 Free Software Foundation, Inc. =20 @@ -21,7 +21,7 @@ print_ver_ ls =20 mkdir dir && touch dir/a dir/b dir/cc || framework_failure_ =20 -LC_ALL=3DC ls --null dir >out || fail=3D1 +LC_ALL=3DC ls --zero dir >out || fail=3D1 tr '\n' '\0' <exp a b --=20 2.30.2 --------------01BBC1DA7F2EF2852F9E256C-- From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 28 07:57:48 2021 Received: (at 49716) by debbugs.gnu.org; 28 Jul 2021 11:57:48 +0000 Received: from localhost ([127.0.0.1]:54801 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m8iC4-0005D0-9q for submit@debbugs.gnu.org; Wed, 28 Jul 2021 07:57:48 -0400 Received: from mail-wr1-f43.google.com ([209.85.221.43]:43609) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m8iC2-0005Co-VN for 49716@debbugs.gnu.org; Wed, 28 Jul 2021 07:57:47 -0400 Received: by mail-wr1-f43.google.com with SMTP id h14so2171646wrx.10 for <49716@debbugs.gnu.org>; Wed, 28 Jul 2021 04:57:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=dHB07VUki3riqE4lSPePSFZPwFz+tWiKL044h710icM=; b=VjVa+qcMWLeBjHBrPnKtn9tBacDLvoWK8JLYep/kv/8ujEZ3lqmbUG76hZAbQXtAdL chidtW8Zfoiv7M6AtIMRDxyqUixxS2jG9J6ZeT3Kg28xhbT+hI0OkEXpg9PgsC2VND98 iI0L6VnxZBg1bJtxzY+mKAl+2Oz+/NrjR0HRaE8VB+rcMGBfCFxCslxvy6lhOtF8C+3T RsNwn5KdMKcO/ju/dYS+oUrH/k63ZMKkfJ65ngpTIb+J4CoIskx6wp3drrP4GaFEDB5b 6anNnn9cCxS6ZR4eBo2U1wKZdXiE1hjlHeypLXN24l9coRsxotYzPpjt25FBAwqi8vR7 EzEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language; bh=dHB07VUki3riqE4lSPePSFZPwFz+tWiKL044h710icM=; b=t4Vf9iWaR/bPGnMRYOQe9tlQn5N6TS3SUTcCyY70/sO5i+ROWTIiPPQyhGHEi1fDbD G+xF8XlIvnZdPe9gzJhUn3PNpndnd7aAIOD0I3qHkgTNMQIxdbQ86MHJbChuGUdLIXFj R97iCTw+pefAgZ+deQqnf7o3ujIjVqaDLH+Ja6mWW5KAy/LWfNSEoeYhX9hcRTqhGjPv EYvruisfcPeG1f9zC4ushZUsh9+OsczVWmdCQgAmsnThnkfDB4T03b9uFSyvF/jdfonu eXJl1b2yMUkSiOiVtzNENxNyFUAb9UMbGNxTsns4GNn1uuWYC96jZ3w2+H/cOuc3viee NG+Q== X-Gm-Message-State: AOAM531wvv4Dk3rhn5EXTpIQFIwUwHbok/ow3s4PGKpOjo+x9yQaMdyL 14QqaZiTzfuoBiTKVexuh1I89EpLt6X+XeLE X-Google-Smtp-Source: ABdhPJzjUwADntPaQgBWlR6Nf5ijdIq0ChbmCp2+5DiBgOR9zIfWLHrA9BXrZv1DL1SpuZ6NlL0Exg== X-Received: by 2002:adf:e6cf:: with SMTP id y15mr18007860wrm.217.1627473460710; Wed, 28 Jul 2021 04:57:40 -0700 (PDT) Received: from localhost.localdomain (86-42-15-3-dynamic.agg2.lod.rsl-rtd.eircom.net. [86.42.15.3]) by smtp.googlemail.com with UTF8SMTPSA id i186sm1418084wmi.43.2021.07.28.04.57.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 28 Jul 2021 04:57:39 -0700 (PDT) Subject: Re: bug#49716: no -print0 for ls? To: Paul Eggert References: <20210724070324.aarmrjo2zn6j7d6z@shells.gnugeneration.com> <368bf886-37a5-961a-9c66-0d818db205bf@draigBrady.com> <20210724163459.dtlctjmkgfllz4cq@shells.gnugeneration.com> <20210724174807.fb2ue4b53q4ia2k4@shells.gnugeneration.com> <73d6ac6a-f70f-295a-2cab-9cd36e827ca4@cs.ucla.edu> <1ccd5c7a-afb8-706d-80aa-9a00128f2674@cs.ucla.edu> <37d3f590-50ee-4c03-df0d-72f3d72a346c@cs.ucla.edu> <91f5dca6-1c8f-9bfa-a311-e30819e8230f@cs.ucla.edu> From: =?UTF-8?Q?P=c3=a1draig_Brady?= Message-ID: Date: Wed, 28 Jul 2021 12:57:38 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Thunderbird/84.0 MIME-Version: 1.0 In-Reply-To: <91f5dca6-1c8f-9bfa-a311-e30819e8230f@cs.ucla.edu> Content-Type: multipart/mixed; boundary="------------838BB5080F0B3C2846A67EFA" Content-Language: en-US X-Spam-Score: 0.4 (/) X-Debbugs-Envelope-To: 49716 Cc: Vito Caputo , 49716@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.6 (/) This is a multi-part message in MIME format. --------------838BB5080F0B3C2846A67EFA Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 28/07/2021 02:14, Paul Eggert wrote: > On 7/26/21 8:00 AM, Pádraig Brady wrote: > >> So I'd have a slight preference for --zero. >> >> Also what about having --zero imply: >>   --quoting-style=literal --show-control-chars --format=single-column >> That seems like a fine shortcut given that would be correct in the vast >> majority of cases, >> and that the need for the above may not be obvious to users. >> >> Also a small point; should --dired disable --null as it may then be non >> parseable? > > Thanks, all good suggestions. For --dired vs --zero I thought it better > simply to prohibit the combination since neither should be in 'ls' shell > aliases, and prohibiting means we can add it later if we like. I > installed the attached patches to do this (plus the other stuff I > mentioned in my reply to Berny). > > The first patch is a cleanup because I had a bit of trouble following > the forest of 'if's inside of ls.c's decode_switches function and I > thought it better to avoid unnecessary syscalls while I was at it. > > The second patch does the real work. > That all looks great. I see --zero implies --format=single-column, but allows --format=long. That's the right default, but also most flexible. I'll apply the attached later to augment/document the test with the various supported option combinations. thanks! Pádraig --------------838BB5080F0B3C2846A67EFA Content-Type: text/x-patch; charset=UTF-8; name="ls--zero-tests.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ls--zero-tests.patch" >From 4f71c9913894a1de0a8a3303fe88f9f75bb25fbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Wed, 28 Jul 2021 12:51:35 +0100 Subject: [PATCH] tests: augment new ls --zero test cases * tests/ls/zero-option.sh: Check for the disabled, disallowed, and allowed option combinations. --- tests/ls/zero-option.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/ls/zero-option.sh b/tests/ls/zero-option.sh index a6883917f..5564f3b77 100755 --- a/tests/ls/zero-option.sh +++ b/tests/ls/zero-option.sh @@ -21,7 +21,15 @@ print_ver_ ls mkdir dir && touch dir/a dir/b dir/cc || framework_failure_ -LC_ALL=C ls --zero dir >out || fail=1 +allowed_options='-l' # explict -l with --zero is allowed +LC_ALL=C ls $allowed_options --zero dir >out || fail=1 +grep '^total' out || fail=1 # Ensure -l honored + +disallowed_options='-l --dired' # dired only enabled with -l +returns_ 2 ls $disallowed_options --zero dir || fail=1 + +disabled_options='--color=always -x -m -C -Q -q' +LC_ALL=C ls $disabled_options --zero dir >out || fail=1 tr '\n' '\0' <exp a b -- 2.26.2 --------------838BB5080F0B3C2846A67EFA-- From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 28 14:39:04 2021 Received: (at 49716) by debbugs.gnu.org; 28 Jul 2021 18:39:04 +0000 Received: from localhost ([127.0.0.1]:55821 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m8oSO-0002vc-BQ for submit@debbugs.gnu.org; Wed, 28 Jul 2021 14:39:04 -0400 Received: from shells.gnugeneration.com ([66.240.222.126]:52324) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m8nlC-0001mk-7t for 49716@debbugs.gnu.org; Wed, 28 Jul 2021 13:54:26 -0400 Received: by shells.gnugeneration.com (Postfix, from userid 1000) id B9FD61A58D21; Wed, 28 Jul 2021 10:54:24 -0700 (PDT) Date: Wed, 28 Jul 2021 10:54:24 -0700 From: Vito Caputo To: =?utf-8?Q?P=C3=A1draig?= Brady Subject: Re: bug#49716: no -print0 for ls? Message-ID: <20210728175424.4sdebqsk2whv7hbz@shells.gnugeneration.com> References: <20210724174807.fb2ue4b53q4ia2k4@shells.gnugeneration.com> <73d6ac6a-f70f-295a-2cab-9cd36e827ca4@cs.ucla.edu> <1ccd5c7a-afb8-706d-80aa-9a00128f2674@cs.ucla.edu> <37d3f590-50ee-4c03-df0d-72f3d72a346c@cs.ucla.edu> <91f5dca6-1c8f-9bfa-a311-e30819e8230f@cs.ucla.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 49716 X-Mailman-Approved-At: Wed, 28 Jul 2021 14:39:02 -0400 Cc: 49716@debbugs.gnu.org, Paul Eggert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) On Wed, Jul 28, 2021 at 12:57:38PM +0100, Pádraig Brady wrote: > On 28/07/2021 02:14, Paul Eggert wrote: > > On 7/26/21 8:00 AM, Pádraig Brady wrote: > > > > > So I'd have a slight preference for --zero. > > > > > > Also what about having --zero imply: > > >   --quoting-style=literal --show-control-chars --format=single-column > > > That seems like a fine shortcut given that would be correct in the vast > > > majority of cases, > > > and that the need for the above may not be obvious to users. > > > > > > Also a small point; should --dired disable --null as it may then be non > > > parseable? > > > > Thanks, all good suggestions. For --dired vs --zero I thought it better > > simply to prohibit the combination since neither should be in 'ls' shell > > aliases, and prohibiting means we can add it later if we like. I > > installed the attached patches to do this (plus the other stuff I > > mentioned in my reply to Berny). > > > > The first patch is a cleanup because I had a bit of trouble following > > the forest of 'if's inside of ls.c's decode_switches function and I > > thought it better to avoid unnecessary syscalls while I was at it. > > > > The second patch does the real work. > > > > That all looks great. > > I see --zero implies --format=single-column, but allows --format=long. > That's the right default, but also most flexible. > > I'll apply the attached later to augment/document the test > with the various supported option combinations. > I'm a bit busy with non-computer work at the moment (building a roof), but will try find some time to kick the tires on these changes in the coming weeks. Thanks all for considering the issue beyond EWONTFIX. Cheers, Vito Caputo From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 28 15:37:49 2021 Received: (at 49716) by debbugs.gnu.org; 28 Jul 2021 19:37:49 +0000 Received: from localhost ([127.0.0.1]:55891 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m8pN6-0000Fv-1w for submit@debbugs.gnu.org; Wed, 28 Jul 2021 15:37:49 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:60422) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m8pN0-0000Fd-Dc for 49716@debbugs.gnu.org; Wed, 28 Jul 2021 15:37:38 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 57335160057; Wed, 28 Jul 2021 12:37:28 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 4XwI2cVwmo5e; Wed, 28 Jul 2021 12:37:21 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 7D2BD16005E; Wed, 28 Jul 2021 12:37:21 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id z02b9f9YmKYu; Wed, 28 Jul 2021 12:37:21 -0700 (PDT) Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 23D41160057; Wed, 28 Jul 2021 12:37:21 -0700 (PDT) To: =?UTF-8?Q?P=c3=a1draig_Brady?= References: <20210724070324.aarmrjo2zn6j7d6z@shells.gnugeneration.com> <368bf886-37a5-961a-9c66-0d818db205bf@draigBrady.com> <20210724163459.dtlctjmkgfllz4cq@shells.gnugeneration.com> <20210724174807.fb2ue4b53q4ia2k4@shells.gnugeneration.com> <73d6ac6a-f70f-295a-2cab-9cd36e827ca4@cs.ucla.edu> <1ccd5c7a-afb8-706d-80aa-9a00128f2674@cs.ucla.edu> <37d3f590-50ee-4c03-df0d-72f3d72a346c@cs.ucla.edu> <91f5dca6-1c8f-9bfa-a311-e30819e8230f@cs.ucla.edu> From: Paul Eggert Organization: UCLA Computer Science Department Subject: Re: bug#49716: no -print0 for ls? Message-ID: <600ee498-1166-c523-417f-f056e3766d30@cs.ucla.edu> Date: Wed, 28 Jul 2021 12:37:14 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------C358C53B058BF5FCEBDF1D47" Content-Language: en-US X-Spam-Score: -2.4 (--) X-Debbugs-Envelope-To: 49716 Cc: Vito Caputo , 49716@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.1 (-) This is a multi-part message in MIME format. --------------C358C53B058BF5FCEBDF1D47 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable On 7/28/21 4:57 AM, P=C3=A1draig Brady wrote: > I see --zero implies --format=3Dsingle-column, but allows --format=3Dlo= ng. > That's the right default, but also most flexible. Yes, it's a little tricky here. For quite some time the ls -1 (digit 1 option) code has disagreed with=20 its documentation. The doc said '-1' is equivalent to=20 '--format=3Dsingle-column', but the code makes '-l -1' equivalent to '-l'= =20 whereas '-l --format=3Dsingle-column' is equivalent to no option at all. I see three possible fixes here: 1. Change the doc to match the code, i.e., change the documentation to=20 say that -1 is not the same thing as --format=3Dsingle-column. 2. Change the code so that --format=3Dsingle-column also has no effect=20 after -l, and change the doc to document this. 3. Change the code to match the doc. (3) would not conform to POSIX, so that's out. (1) is less work for us=20 and does not affect existing uses, so I installed the first attached=20 patch to implement (1). This first patch also cleans up a bunch of other=20 documentation cruft that I noticed in the 'ls' documentation. The second=20 patch updates up some old-fashioned terminology I noticed while working=20 on the first patch. You could talk me into (2), I suppose.... --------------C358C53B058BF5FCEBDF1D47 Content-Type: text/x-patch; charset=UTF-8; name="0001-doc-improve-ls-documentation.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-doc-improve-ls-documentation.patch" =46rom dd6591b20e0841e5aecaa082bac1f959a5e18f9c Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 28 Jul 2021 11:26:48 -0700 Subject: [PATCH 1/2] doc: improve ls documentation MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit * doc/coreutils.texi (ls invocation): Document implementation more closely. Be more consistent about style. Omit some needless words. * src/ls.c (usage): Don=E2=80=99t overdocument -f, as the details were wr= ong. Omit -1 advice as it=E2=80=99s a bit obsolete now that we have --zero and= is a bit much for --usage output anyway. --- doc/coreutils.texi | 173 ++++++++++++++++++++++++--------------------- src/ls.c | 15 ++-- 2 files changed, 99 insertions(+), 89 deletions(-) diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 2d2770864..64cadf634 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -7350,7 +7350,8 @@ and @command{vdir}, which list information about fi= les. =20 The @command{ls} program lists information about files (of any type, including directories). Options and file arguments can be intermixed -arbitrarily, as usual. +arbitrarily, as usual. Later options override earlier options that +are incompatible. =20 For non-option command-line arguments that are directories, by default @command{ls} lists the contents of directories, not recursively, and @@ -7460,10 +7461,10 @@ Do not dereference symbolic links, with one excep= tion: if a command line argument specifies a symbolic link that refers to a directory, show information for that directory rather than for the link itself. -This is the default behavior when no other dereferencing-related -option has been specified (@option{--classify} (@option{-F}), +This is the default behavior unless long format is being used +or any of the following options is in effect: +@option{--classify} (@option{-F}), @option{--directory} (@option{-d}), -(@option{-l}), @option{--dereference} (@option{-L}), or @option{--dereference-command-line} (@option{-H})). =20 @@ -7541,7 +7542,7 @@ default, only file names are shown. @item --author @opindex --author @cindex hurd, author, printing -List each file's author when producing long format directory listings. +In long format, list each file's author. In GNU/Hurd, file authors can differ from their owners, but in other operating systems the two are the same. =20 @@ -7550,8 +7551,7 @@ operating systems the two are the same. @opindex -D @opindex --dired @cindex dired Emacs mode support -With the long listing (@option{-l}) format, print an additional line aft= er -the main output: +Print an additional line after the main output: =20 @example //DIRED// @var{beg1} @var{end1} @var{beg2} @var{end2} @dots{} @@ -7563,7 +7563,8 @@ byte position of the beginning and end of each file= name in the output. This makes it easy for Emacs to find the names, even when they contain unusual characters such as space or newline, without fancy searching. =20 -If directories are being listed recursively (@option{-R}), output a simi= lar +If directories are being listed recursively via +@option{--recursive} (@option{-R}), output a similar line with offsets for each subdirectory name: =20 @example @@ -7608,7 +7609,7 @@ $ ls -gloRF --dired a //DIRED-OPTIONS// --quoting-style=3Dliteral @end example =20 -Note that the pairs of offsets on the @samp{//DIRED//} line above delimi= t +The pairs of offsets on the @samp{//DIRED//} line above delimit these names: @file{f1}, @file{f2}, @file{sub}, @file{sub2}, @file{deeper= }, @file{file}. The offsets on the @samp{//SUBDIRED//} line delimit the following @@ -7623,11 +7624,12 @@ $ dd bs=3D1 skip=3D222 count=3D6 < out 2>/dev/nul= l; echo deeper @end example =20 -Note that although the listing above includes a trailing slash +Although the listing above includes a trailing slash for the @samp{deeper} entry, the offsets select the name without the trailing slash. However, if you invoke @command{ls} with @option{--= dired} -along with an option like @option{--escape} (aka @option{-b}) and operat= e -on a file whose name contains special characters, notice that the backsl= ash +(@option{-D}) along with an option like +@option{--escape} (@option{-b}) and operate +on a file whose name contains special characters, the backslash @emph{is} included: =20 @example @@ -7638,29 +7640,33 @@ $ ls -blog --dired 'a b' //DIRED-OPTIONS// --quoting-style=3Descape @end example =20 -If you use a quoting style that adds quote marks -(e.g., @option{--quoting-style=3Dc}), then the offsets include the quote= marks. +If you use a quoting style like @option{--quoting-style=3Dc} (@option{-Q= }) +that adds quote marks, then the offsets include the quote marks. So beware that the user may select the quoting style via the environment= variable @env{QUOTING_STYLE}@. Hence, applications using @option{--dire= d} -should either specify an explicit @option{--quoting-style=3Dliteral} opt= ion -(aka @option{-N} or @option{--literal}) on the command line, or else be +should either specify an explicit @option{--quoting-style=3Dliteral} +(@option{-N}) option on the command line, or else be prepared to parse the escaped names. =20 +The @option{--dired} (@option{-D}) option has well-defined behavior +only when long format is in effect and hyperlinks are disabled (e.g., +@option{--hyperlink=3Dnone}). + @item --full-time @opindex --full-time -Produce long format directory listings, and list times in full. It is -equivalent to using @option{--format=3Dlong} with +Produce long format, and list times in full. It is +equivalent to using @option{--format=3Dlong} (@option{-l}) with @option{--time-style=3Dfull-iso} (@pxref{Formatting file timestamps}). =20 @item -g @opindex -g -Produce long format directory listings, but don't display owner informat= ion. +Produce long format, but omit owner information. =20 @item -G @itemx --no-group @opindex -G @opindex --no-group -Inhibit display of group information in a long format directory listing.= +Inhibit display of group information in long format. (This is the default in some non-GNU versions of @command{ls}, so we provide this option for compatibility.) =20 @@ -7682,6 +7688,7 @@ uniquely identifies each file within a particular f= ile system.) @opindex --format @opindex long ls @r{format} @opindex verbose ls @r{format} +Produce long format. In addition to the name of each file, print the file type, file mode bit= s, number of hard links, owner name, group name, size, and timestamp (@pxref{Formatting file timestamps}), normally @@ -7693,7 +7700,8 @@ Print question marks for other information that cannot be determined. =20 Normally the size is printed as a byte count without punctuation, but -this can be overridden (@pxref{Block size}). For example, @option{-h} +this can be overridden (@pxref{Block size}). +For example, @option{--human-readable} (@option{-h}) prints an abbreviated, human-readable count, and @samp{--block-size=3D"'1"} prints a byte count with the thousands separator of the current locale. @@ -7798,14 +7806,15 @@ is marked with a @samp{+} character. @opindex --numeric-uid-gid @cindex numeric uid and gid @cindex numeric user and group IDs -Produce long format directory listings, but +Produce long format, but display right-justified numeric user and group IDs instead of left-justified owner and group names. =20 @item -o @opindex -o -Produce long format directory listings, but don't display group informat= ion. -It is equivalent to using @option{--format=3Dlong} with @option{--no-gro= up} . +Produce long format, but omit group information. +It is equivalent to using @option{--format=3Dlong} (@option{-l}) +with @option{--no-group} (@option{-G}). =20 @item -s @itemx --size @@ -7836,8 +7845,7 @@ it also affects the HP-UX @command{ls} program. @cindex SELinux @cindex security context Display the SELinux security context or @samp{?} if none is found. -When used with the @option{-l} option, print the security context -to the left of the size column. +In long format, print the security context to the left of the size colum= n. =20 @end table =20 @@ -7860,20 +7868,20 @@ it outputs. By default, sorting is done by chara= cter code @opindex ctime@r{, printing or sorting by} @opindex status time@r{, printing or sorting by} @opindex use time@r{, printing or sorting files by} -If the long listing format (e.g., @option{-l}, @option{-o}) is being use= d, +In long format, print the status change timestamp (the ctime) instead of the mtime. -When explicitly sorting by time (@option{--sort=3Dtime} or @option{-t}) -or when not using a long listing format, +When sorting by time or when not using long format, sort according to the ctime. @xref{File timestamps}. =20 @item -f @opindex -f @cindex unsorted directory listing @cindex directory order, listing by -Primarily, like @option{-U}---do not sort; list the files in whatever -order they are stored in the directory. But also enable @option{-a} (li= st -all files) and disable @option{-l}, @option{--color}, and @option{-s} (i= f they -were specified before the @option{-f}). +Produce an unsorted directory listing. +This is equivalent to the combination of @option{--all} (@option{-a}), +@option{--sort=3Dnone} (@option{-U}), @option{-1}, +@option{--color=3Dnone}, and @option{--hyperlink=3Dnone}, +while also disabling any previous use of @option{--size} (@option{-s}). =20 @item -r @itemx --reverse @@ -7882,6 +7890,8 @@ were specified before the @option{-f}). @cindex reverse sorting Reverse whatever the sorting method is---e.g., list files in reverse alphabetical order, youngest first, smallest first, or whatever. +This option has no effect when @option{--sort=3Dnone} (@option{-U}) +is in effect. =20 @item -S @itemx --sort=3Dsize @@ -7908,10 +7918,9 @@ The timestamp to order by can be changed with the = @option{--time} option. @opindex use time@r{, printing or sorting files by} @opindex atime@r{, printing or sorting files by} @opindex access timestamp@r{, printing or sorting files by} -If the long listing format (e.g., @option{--format=3Dlong}) is being use= d, -print the last access timestamp (the atime). -When explicitly sorting by time (@option{--sort=3Dtime} or @option{-t}) -or when not using a long listing format, sort according to the atime. +In long format, print the last access timestamp (the atime). +When sorting by time or when not using long format, +sort according to the atime. @xref{File timestamps}. =20 @item --time=3Dbirth @@ -7919,10 +7928,9 @@ or when not using a long listing format, sort acco= rding to the atime. @opindex --time @opindex birth time@r{, printing or sorting files by} @opindex creation timestamp@r{, printing or sorting files by} -If the long listing format (e.g., @option{--format=3Dlong}) is being use= d, -print the file creation timestamp if available. -When explicitly sorting by time (@option{--sort=3Dtime} or @option{-t}) -or when not using a long listing format, sort according to the birth tim= e. +In long format, print the file creation timestamp if available. +When sorting by time or when not using long format, +sort according to the birth time. @xref{File timestamps}. =20 @item -U @@ -7932,8 +7940,8 @@ or when not using a long listing format, sort accor= ding to the birth time. @opindex none@r{, sorting option for @command{ls}} Do not sort; list the files in whatever order they are stored in the directory. (Do not do any of the other unrelated things -that @option{-f} does.) This is especially useful when listing very lar= ge -directories, since not doing any sorting can be noticeably faster. +that @option{-f} does.) This can be useful when listing large +directories, where sorting can take some time. =20 @item -v @itemx --sort=3Dversion @@ -7942,13 +7950,13 @@ directories, since not doing any sorting can be n= oticeably faster. @opindex version@r{, sorting option for @command{ls}} Sort by version name and number, lowest first. It behaves like a defaul= t sort, except that each sequence of decimal digits is treated numerically= -as an index/version number. (@xref{Version sort ordering}.) +as an index/version number. @xref{Version sort ordering}. =20 @item --sort=3Dwidth @opindex --sort @opindex width@r{, sorting option for @command{ls}} Sort by printed width of file names. -This is especially useful with the default @option{--format=3Dvertical} +This can be useful with the @option{--format=3Dvertical} (@option{-C}) output format, to most densely display the listed files. =20 @item -X @@ -7969,30 +7977,35 @@ These options affect the appearance of the overal= l output. =20 @table @samp =20 -@item -1 -@itemx --format=3Dsingle-column -@opindex -1 +@item --format=3Dsingle-column @opindex --format @opindex single-column @r{output of files} -List one file per line. This is the default for @command{ls} when stand= ard -output is not a terminal. See also the @option{-b} and @option{-q} opti= ons -to suppress direct output of newline characters within a file name. +List one file name per line, with no other information. +This is the default for @command{ls} when standard +output is not a terminal. See also the @option{--escape} (@option{-b}),= +@option{--hide-control-chars} (@option{-q}), and @option{--zero} options= +to disambiguate output of file names containing newline characters. + +@item -1 +@opindex -1 +List one file per line. This is like @option{--format=3Dsingle-column} +except that it has no effect if long format is also in effect. =20 @item -C @itemx --format=3Dvertical @opindex -C @opindex --format @opindex vertical @r{sorted files in columns} -List files in columns, sorted vertically. This is the default for -@command{ls} if standard output is a terminal. It is always the default= -for the @command{dir} program. +List files in columns, sorted vertically, with no other information. +This is the default for @command{ls} if standard output is a terminal. +It is always the default for the @command{dir} program. GNU @command{ls} uses variable width columns to display as many files as= possible in the fewest lines. =20 @item --color [=3D@var{when}] @opindex --color @cindex color, distinguishing file types with -Specify whether to use color for distinguishing file types. @var{when} +Specify whether to use color for distinguishing file types; @var{when} may be omitted, or one of: @itemize @bullet @item none @@ -8009,12 +8022,12 @@ may be omitted, or one of: Specifying @option{--color} and no @var{when} is equivalent to @option{--color=3Dalways}. If piping a colorized listing through a pager like @command{less}, -use the @option{-R} option to pass the color codes to the terminal. +use the pager's @option{-R} option to pass the color codes to the termin= al. =20 @vindex LS_COLORS @vindex SHELL @r{environment variable, and color} -Note that using the @option{--color} option may incur a noticeable -performance penalty when run in a directory with very many entries, +Using the @option{--color} option may incur a noticeable +performance penalty when run in a large directory, because the default settings require that @command{ls} @code{stat} every= single file it lists. However, if you would like most of the file-type coloring @@ -8068,7 +8081,7 @@ command line unless the @option{--dereference-comma= nd-line} (@option{-H}), @opindex --indicator-style @cindex file type, marking Append a character to each file name indicating the file type. This is -like @option{-F}, except that executables are not marked. +like @option{--classify} (@option{-F}, except that executables are not m= arked. =20 @item --hyperlink [=3D@var{when}] @opindex --hyperlink @@ -8108,8 +8121,8 @@ for FIFOs, @samp{=3D} for sockets, and nothing for = regular files. This is the same as the @option{--file-type} option. @item classify Append @samp{*} for executable regular files, otherwise behave as for -@samp{file-type}. This is the same as the @option{-F} or -@option{--classify} option. +@samp{file-type}. This is the same as the @option{--classify} +(@option{-F}) option. @end table =20 @item -k @@ -8118,16 +8131,15 @@ Append @samp{*} for executable regular files, oth= erwise behave as for @opindex --kibibytes Set the default block size to its normal value of 1024 bytes, overriding any contrary specification in environment variables -(@pxref{Block size}). If @option{--block-size}, @option{-h}, -@option{--human-readable}, or @option{--si} options are used, -they take precedence over @option{-k} or @option{--kibibytes} -even if @option{-k} or @option{--kibibytes} is placed after -the other options. +(@pxref{Block size}). If @option{--block-size}, +@option{--human-readable} (@option{-h}), or @option{--si} options are us= ed, +they take precedence even if @option{--kibibytes} (@option{-k}) is place= d after =20 -The @option{-k} or @option{--kibibytes} option affects the -per-directory block count written by the @option{-l} and similar -options, and the size written by the @option{-s} or @option{--size} -option. It does not affect the file size written by @option{-l}. +The @option{--kibibytes} (@option{-k}) option affects the +per-directory block count written in long format, +and the disk allocation written by the @option{--size} (@option{-s}) +option. It does not affect the file size in bytes that is written in +long format. =20 @item -m @itemx --format=3Dcommas @@ -8135,17 +8147,16 @@ option. It does not affect the file size written= by @option{-l}. @opindex --format @opindex commas@r{, outputting between files} List files horizontally, with as many as will fit on each line, -separated by @samp{, } (a comma and a space). +separated by @samp{, } (a comma and a space), +and with no other information. =20 @item --zero @opindex --zero -This option is incompatible with the @option{-D} or @option{--dired} opt= ion. -This option also implies the options -@option{--show-control-chars}, -@option{-1} or @option{--format=3Dsingle-column}, -@option{--color=3Dnone}, and -@option{-N} or @option{--quoting-style=3Dliteral}. @outputNUL +This option is incompatible with the @option{--dired} (@option{-D}) opti= on. +This option also implies the options @option{--show-control-chars}, +@option{-1}, @option{--color=3Dnone}, and +@option{--quoting-style=3Dliteral} (@option{-N}). =20 @item -p @itemx --indicator-style=3Dslash @@ -8375,8 +8386,8 @@ be one of the following: @macro quotingStyles @table @samp @item literal -Output strings as-is; this is the same as the @option{-N} or -@option{--literal} option. +Output strings as-is; this is the same as the @option{--literal} (@optio= n{-N}) +option. @item shell Quote strings for the shell if they contain shell metacharacters or woul= d cause ambiguous output. @@ -8394,11 +8405,11 @@ normally not require quoting. @item c Quote strings as for C character string literals, including the surrounding double-quote characters; this is the same as the -@option{-Q} or @option{--quote-name} option. +@option{--quote-name} (@option{-Q}) option. @item escape Quote strings as for C character string literals, except omit the surrounding double-quote -characters; this is the same as the @option{-b} or @option{--escape} opt= ion. +characters; this is the same as the @option{--escape} (@option{-b}) opti= on. @item clocale Quote strings as for C character string literals, except use surrounding quotation marks appropriate for the diff --git a/src/ls.c b/src/ls.c index 7ea956227..b2e753dc8 100644 --- a/src/ls.c +++ b/src/ls.c @@ -1938,15 +1938,15 @@ decode_switches (int argc, char **argv) break; =20 case 'f': - /* Same as enabling -a -U and disabling -l -s. */ + /* Same as -a -U -1 --color=3Dnone --hyperlink=3Dnone, + while disabling -s. */ ignore_mode =3D IGNORE_MINIMAL; sort_opt =3D sort_none; - /* disable -l */ if (format_opt =3D=3D long_format) format_opt =3D -1; - print_block_size =3D false; /* disable -s */ - print_with_color =3D false; /* disable --color */ - print_hyperlink =3D false; /* disable --hyperlink */ + print_with_color =3D false; + print_hyperlink =3D false; + print_block_size =3D false; break; =20 case FILE_TYPE_INDICATOR_OPTION: /* --file-type */ @@ -5428,7 +5428,7 @@ Sort entries alphabetically if none of -cftuvSUX no= r --sort is specified.\n\ -D, --dired generate output designed for Emacs' dired m= ode\n\ "), stdout); fputs (_("\ - -f do not sort, enable -aU, disable -ls --colo= r\n\ + -f list all entries in directory order\n\ -F, --classify[=3DWHEN] append indicator (one of */=3D>@|) to ent= ries;\n\ WHEN can be 'always' (default if omitted)= ,\n\ 'auto', or 'never'\n\ @@ -5543,8 +5543,7 @@ Sort entries alphabetically if none of -cftuvSUX no= r --sort is specified.\n\ -X sort alphabetically by entry extension\n\ -Z, --context print any security context of each file\n\ --zero end each output line with NUL, not newline\= n\ - -1 list one file per line. Avoid '\\n' with -= q or -b\ -\n\ + -1 list one file per line\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); --=20 2.30.2 --------------C358C53B058BF5FCEBDF1D47 Content-Type: text/x-patch; charset=UTF-8; name="0002-doc-modernize-usage-of-disk-and-core.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0002-doc-modernize-usage-of-disk-and-core.patch" =46rom 7ffb9fbdec192ab00323061a99340c59fcc983df Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 28 Jul 2021 12:22:11 -0700 Subject: [PATCH 2/2] =3D?UTF-8?q?doc:=3D20modernize=3D20usage=3D20of=3D20= =3DE2=3D80=3D9Cdi?=3D =3D?UTF-8?q?sk=3DE2=3D80=3D9D=3D20and=3D20=3DE2=3D80=3D9Ccore=3DE2=3D80=3D= 9D?=3D MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit In documentation and comments, don=E2=80=99t assume that secondary storag= e devices are disk devices. Similarly, don=E2=80=99t assume that main memo= ry uses magnetic cores, which became obsolete in the 1970s. * src/du.c (usage): * src/ls.c (usage): * src/shred.c (usage): Reword to avoid =E2=80=9Cdisk=E2=80=9D in usage me= ssages. --- README-hacking | 2 +- doc/coreutils.texi | 155 +++++++++++++++++---------------- init.cfg | 3 +- man/df.x | 10 +-- src/copy.c | 2 +- src/copy.h | 2 +- src/dd.c | 8 +- src/df.c | 62 ++++++------- src/du.c | 10 +-- src/factor.c | 3 +- src/ioblksize.h | 2 +- src/ls.c | 2 +- src/ptx.c | 2 +- src/shred.c | 6 +- src/sort.c | 6 +- src/system.h | 2 +- src/tsort.c | 2 +- tests/cp/sparse-extents.sh | 2 +- tests/df/df-P.sh | 2 +- tests/df/df-symlink.sh | 11 +-- tests/du/8gb.sh | 2 +- tests/du/basic.sh | 2 +- tests/du/deref.sh | 4 +- tests/misc/help-version.sh | 2 +- tests/other-fs-tmpdir | 2 +- tests/rm/ext3-perf.sh | 6 +- tests/tail-2/inotify-rotate.sh | 2 +- 27 files changed, 161 insertions(+), 153 deletions(-) diff --git a/README-hacking b/README-hacking index b7bca9ec7..be9ea3766 100644 --- a/README-hacking +++ b/README-hacking @@ -30,7 +30,7 @@ You can get a copy of the source repository like this: =20 As an optional step, if you already have a copy of the gnulib git repository, then you can use it as a reference to reduce download -time and disk space requirements: +time and file system space requirements: =20 $ export GNULIB_SRCDIR=3D/path/to/gnulib =20 diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 64cadf634..95f9466a0 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -55,11 +55,11 @@ * cut: (coreutils)cut invocation. Print selected parts of = lines. * date: (coreutils)date invocation. Print/set system date an= d time. * dd: (coreutils)dd invocation. Copy and convert a file.= -* df: (coreutils)df invocation. Report file system disk = usage. +* df: (coreutils)df invocation. Report file system usage= =2E * dir: (coreutils)dir invocation. List directories briefly= =2E * dircolors: (coreutils)dircolors invocation. Color setup for ls. * dirname: (coreutils)dirname invocation. Strip last file name com= ponent. -* du: (coreutils)du invocation. Report on disk usage. +* du: (coreutils)du invocation. Report file usage. * echo: (coreutils)echo invocation. Print a line of text. * env: (coreutils)env invocation. Modify the environment. * expand: (coreutils)expand invocation. Convert tabs to spaces. @@ -116,7 +116,7 @@ * stdbuf: (coreutils)stdbuf invocation. Modify stdio buffering. * stty: (coreutils)stty invocation. Print/change terminal se= ttings. * sum: (coreutils)sum invocation. Print traditional checks= um. -* sync: (coreutils)sync invocation. Synchronize memory to di= sk. +* sync: (coreutils)sync invocation. Sync files to stable sto= rage. * tac: (coreutils)tac invocation. Reverse files. * tail: (coreutils)tail invocation. Output the last part of = files. * tee: (coreutils)tee invocation. Redirect to multiple fil= es. @@ -196,7 +196,7 @@ Free Documentation License''. * Basic operations:: cp dd install mv rm shred * Special file types:: mkdir rmdir unlink mkfifo mknod ln link r= eadlink * Changing file attributes:: chgrp chmod chown touch -* Disk usage:: df du stat sync truncate +* File space usage:: df du stat sync truncate * Printing text:: echo printf yes * Conditions:: false true test expr * Redirection:: tee @@ -346,9 +346,9 @@ Changing file attributes * chmod invocation:: Change access permissions * touch invocation:: Change file timestamps =20 -Disk usage +File space usage =20 -* df invocation:: Report file system disk space usage +* df invocation:: Report file system space usage * du invocation:: Estimate file space usage * stat invocation:: Report file or file system status * sync invocation:: Synchronize cached writes to persistent= storage @@ -3335,7 +3335,7 @@ write through a pipe to the specified shell @var{co= mmand} for each output file. @var{command} should use the $FILE environment variable, which is set to a different output file name for each invocation of the command. For example, imagine that you have a 1TiB compressed file -that, if uncompressed, would be too large to reside on disk, +that, if uncompressed, would be too large to reside on secondary storage= , yet you must split it into individually-compressed pieces of a more manageable size. To do that, you might run this command: @@ -4703,7 +4703,7 @@ Use directory @var{tempdir} to store temporary file= s, overriding the once, temporary files are stored in all the directories given. If you have a large sort or merge that is I/O-bound, you can often improve performance by using this option to specify directories on different -disks and controllers. +file systems. =20 @item --parallel=3D@var{n} @opindex --parallel @@ -7707,7 +7707,7 @@ prints an abbreviated, human-readable count, and separator of the current locale. =20 For each directory that is listed, preface the files with a line -@samp{total @var{blocks}}, where @var{blocks} is the total disk allocati= on +@samp{total @var{blocks}}, where @var{blocks} is the file system allocat= ion for all files in that directory. The block size currently defaults to 1= 024 bytes, but this can be overridden (@pxref{Block size}). The @var{blocks} computed counts each hard link separately; @@ -7820,13 +7820,13 @@ with @option{--no-group} (@option{-G}). @itemx --size @opindex -s @opindex --size -@cindex disk allocation +@cindex file system allocation @cindex size of files, reporting -Print the disk allocation of each file to the left of the file name. -This is the amount of disk space used by the file, which is usually a +Print the file system allocation of each file to the left of the file na= me. +This is the amount of file system space used by the file, which is usual= ly a bit more than the file's size, but it can be less if the file has holes.= =20 -Normally the disk allocation is printed in units of +Normally the allocation is printed in units of 1024 bytes, but this can be overridden (@pxref{Block size}). =20 @cindex NFS mounts from BSD to HP-UX @@ -8137,7 +8137,7 @@ they take precedence even if @option{--kibibytes} (= @option{-k}) is placed after =20 The @option{--kibibytes} (@option{-k}) option affects the per-directory block count written in long format, -and the disk allocation written by the @option{--size} (@option{-s}) +and the file system allocation written by the @option{--size} (@option{-= s}) option. It does not affect the file size in bytes that is written in long format. =20 @@ -8691,7 +8691,7 @@ normally has undesirable effects on special files l= ike FIFOs and the ones typically found in the @file{/dev} directory. In most cases, @code{cp -R --copy-contents} will hang indefinitely trying to read from FIFOs and special files like @file{/dev/console}, and it will -fill up your destination disk if you use it to copy @file{/dev/zero}. +fill up your destination file system if you use it to copy @file{/dev/ze= ro}. This option has no effect unless copying recursively, and it does not affect the copying of symbolic links. =20 @@ -8902,8 +8902,8 @@ implementations that dereference symbolic links by = default. @cindex copy on write Perform a lightweight, copy-on-write (COW) copy, if supported by the file system. Once it has succeeded, beware that the source and destinat= ion -files share the same disk data blocks as long as they remain unmodified.= -Thus, if a disk I/O error affects data blocks of one of the files, +files share the same data blocks as long as they remain unmodified. +Thus, if an I/O error affects data blocks of one of the files, the other suffers the same fate. =20 The @var{when} value can be one of the following: @@ -8938,8 +8938,8 @@ Remove each existing destination file before attemp= ting to open it @cindex holes, copying files with @findex read @r{system call, and holes} A @dfn{sparse file} contains @dfn{holes}---a sequence of zero bytes that= -does not occupy any physical disk blocks; the @samp{read} system call -reads these as zeros. This can both save considerable disk space and +does not occupy any file system blocks; the @samp{read} system call +reads these as zeros. This can both save considerable space and increase speed, since many binary files contain lots of consecutive zero= bytes. By default, @command{cp} detects holes in input source files via= a crude heuristic and makes the corresponding output file sparse as well. @@ -9519,25 +9519,25 @@ multiple of the I/O@ block size, you can use the = @samp{skip_bytes}, @samp{seek_bytes} and @samp{count_bytes} flags. Alternatively the traditional method of separate @command{dd} invocations can be used.= For example, the following shell commands copy data -in 512 KiB blocks between a disk and a tape, but do not save -or restore a 4 KiB label at the start of the disk: +in 512 KiB blocks between a flash drive and a tape, but do not save +or restore a 1 MiB area at the start of the flash drive: =20 @example -disk=3D/dev/rdsk/c0t1d0s2 -tape=3D/dev/rmt/0 +flash=3D/dev/sda +tape=3D/dev/st0 =20 -# Copy all but the label from disk to tape. -(dd bs=3D4k skip=3D1 count=3D0 && dd bs=3D512k) <$disk >$tape +# Copy all but the initial 1 MiB from flash to tape. +(dd bs=3D1M skip=3D1 count=3D0 && dd bs=3D512k) <$flash >$tape =20 -# Copy from tape back to disk, but leave the disk label alone. -(dd bs=3D4k seek=3D1 count=3D0 && dd bs=3D512k) <$tape >$disk +# Copy from tape back to flash, leaving initial 1 MiB alone. +(dd bs=3D1M seek=3D1 count=3D0 && dd bs=3D512k) <$tape >$flash @end example =20 @cindex ddrescue -@cindex disks, failing -For failing disks, other tools come with a great variety of extra +@cindex storage devices, failing +For failing storage devices, other tools come with a great variety of ex= tra functionality to ease the saving of as much data as possible before the -disk finally dies, e.g. +device finally dies, e.g. @uref{https://www.gnu.org/software/ddrescue/, GNU @command{ddrescue}}. However, in some cases such a tool is not available or the administrator= feels more comfortable with the handling of @command{dd}. @@ -9545,10 +9545,10 @@ As a simple rescue method, call @command{dd} as s= hown in the following example: the operand @samp{conv=3Dnoerror,sync} is used to continue after read errors and to pad out bad reads with NULs, while @samp{iflag=3Dfullblock} caters for short reads (which traditionally nev= er -occur on disk based devices): +occur on flash or similar devices): =20 @example -# Rescue data from an (unmounted!) partition of a failing disk. +# Rescue data from an (unmounted!) partition of a failing device. dd conv=3Dnoerror,sync iflag=3Dfullblock /mnt/rescue.img @end example =20 @@ -10278,7 +10278,8 @@ the optional @var{how} parameter, supported with = the long form option, gives control of how to more efficiently remove each directory entry. The @samp{unlink} parameter will just use a standard unlink call, @samp{wipe} will also first obfuscate bytes in the name, and -@samp{wipesync} will also sync each obfuscated byte in the name to disk.= +@samp{wipesync} will also sync each obfuscated byte in the name to +the file system. Note @samp{wipesync} is the default method, but can be expensive, requiring a sync for every character in every file. This can become significant with many files, or is redundant if your file system provide= s @@ -10327,7 +10328,7 @@ shred -v -n 1 /dev/sdd1 @end example =20 Similarly, to erase all data on a selected partition of -your hard disk, you could give a command like the following. +your device, you could give a command like the following. =20 @example # 1 pass, write pseudo-random data; 3x faster than the default @@ -10336,7 +10337,7 @@ shred -v -n1 /dev/sda5 =20 To be on the safe side, use at least one pass that overwrites using pseudo-random data. I.e., don't be tempted to use @samp{-n0 --zero}, -in case some disk controller optimizes the process of writing blocks +in case some device controller optimizes the process of writing blocks of all zeros, and thereby does not clear all bytes in a block. Some SSDs may do just that. =20 @@ -10838,7 +10839,7 @@ mknod [@var{option}]@dots{} @var{name} @var{type}= [@var{major} @var{minor}] Unlike the phrase ``special file type'' above, the term @dfn{special file} has a technical meaning on Unix: something that can generate or receive data. Usually this corresponds to a physical piece of hardware,= -e.g., a printer or a disk. (These files are typically created at +e.g., a printer or a flash drive. (These files are typically created at= system-configuration time.) The @command{mknod} command is what creates= files of this type. Such devices can be read either a character at a time or a ``block'' (many characters) at a time, hence we say there are @@ -11752,17 +11753,18 @@ For example, use @samp{touch ./12312359 main.c}= or @samp{touch -t @exitstatus =20 =20 -@node Disk usage -@chapter Disk usage +@node File space usage +@chapter File space usage =20 +@cindex File space usage @cindex disk usage =20 -No disk can hold an infinite amount of data. These commands report -how much disk storage is in use or available, report other file and -file status information, and write buffers to disk. +No file system can hold an infinite amount of data. These commands repo= rt +how much storage is in use or available, report other file and +file status information, and write buffers to file systems. =20 @menu -* df invocation:: Report file system disk space usage. +* df invocation:: Report file system space usage. * du invocation:: Estimate file space usage. * stat invocation:: Report file or file system status. * sync invocation:: Synchronize cached writes to persistent = storage. @@ -11771,13 +11773,13 @@ file status information, and write buffers to d= isk. =20 =20 @node df invocation -@section @command{df}: Report file system disk space usage +@section @command{df}: Report file system space usage =20 @pindex df -@cindex file system disk usage +@cindex file system usage @cindex disk usage by file system =20 -@command{df} reports the amount of disk space used and available on +@command{df} reports the amount of space used and available on file systems. Synopsis: =20 @example @@ -11788,7 +11790,7 @@ With no arguments, @command{df} reports the space= used and available on all currently mounted file systems (of all types). Otherwise, @command{df} reports on the file system containing each argument @var{file}. =20 -Normally the disk space is printed in units of +Normally the space is printed in units of 1024 bytes, but this can be overridden (@pxref{Block size}). Non-integer quantities are rounded up to the next higher unit. =20 @@ -11803,11 +11805,11 @@ the same device number, e.g. the early-boot pse= udo file system @samp{rootfs} is not shown per default when already the real root device has been mounted= =2E =20 @cindex disk device file -@cindex device file, disk +@cindex device file If an argument @var{file} resolves to a special file containing a mounted file system, @command{df} shows the space available on that file system rather than on the file system containing the device node. -GNU @command{df} does not attempt to determine the disk usage +GNU @command{df} does not attempt to determine the usage on unmounted file systems, because on most kinds of systems doing so requires extremely nonportable intimate knowledge of file system structu= res. =20 @@ -11850,7 +11852,7 @@ Equivalent to @option{--si}. @cindex inode usage List inode usage information instead of block usage. An inode (short for index node) contains information about a file such as its owner, -permissions, timestamps, and location on the disk. +permissions, timestamps, and location on the file system. =20 @item -k @opindex -k @@ -11872,7 +11874,7 @@ are also listed. @cindex file system space, retrieving old data more quickly Do not invoke the @code{sync} system call before getting any usage data.= This may make @command{df} run significantly faster on systems with many= -disks, but on some systems (notably Solaris) the results may be slightly= +file systems, but on some systems (notably Solaris) the results may be s= lightly out of date. This is the default. =20 @item --output @@ -11979,9 +11981,9 @@ there are many or very busy file systems. =20 @item --total @opindex --total -@cindex grand total of disk size, usage and available space +@cindex grand total of file system size, usage and available space Print a grand total of all arguments after all arguments have -been processed. This can be used to find out the total disk size, usage= +been processed. This can be used to find out the total size, usage and available space of all listed devices. If no arguments are specifie= d df will try harder to elide file systems insignificant to the total available space, by suppressing duplicate remote file systems. @@ -12027,7 +12029,7 @@ all systems. @opindex ext4 @r{file system type} @opindex xfs @r{file system type} @opindex btrfs @r{file system type} -A file system on a locally-mounted hard disk. (The system might even +A file system on a locally-mounted device. (The system might even support more than one type here; GNU/Linux does.) =20 @item iso9660@r{, }cdfs @@ -12085,15 +12087,16 @@ or @option{-x} is used together with a file nam= e argument. @cindex file space usage @cindex disk usage for files =20 -@command{du} reports the amount of disk space used by the set of specifi= ed files -and for each subdirectory (of directory arguments). Synopsis: +@command{du} reports the amount of file system space used by the set +of specified files and for each subdirectory (of directory arguments). +Synopsis: =20 @example du [@var{option}]@dots{} [@var{file}]@dots{} @end example =20 -With no arguments, @command{du} reports the disk space for the current -directory. Normally the disk space is printed in units of +With no arguments, @command{du} reports the file system space for the cu= rrent +directory. Normally the space is printed in units of 1024 bytes, but this can be overridden (@pxref{Block size}). Non-integer quantities are rounded up to the next higher unit. =20 @@ -12116,12 +12119,12 @@ Show counts for all files, not just directories= =2E =20 @item --apparent-size @opindex --apparent-size -Print apparent sizes, rather than disk usage. The apparent size of a +Print apparent sizes, rather than file system usage. The apparent size = of a file is the number of bytes reported by @code{wc -c} on regular files, or more generally, @code{ls -l --block-size=3D1} or @code{stat --format=3D= %s}. For example, a file containing the word @samp{zoo} with no newline would= , of course, have an apparent size of 3. Such a small file may require -anywhere from 0 to 16 KiB or more of disk space, depending on +anywhere from 0 to 16 KiB or more of file system space, depending on the type and configuration of the file system on which the file resides.= However, a sparse file created with this command: =20 @@ -12131,7 +12134,7 @@ dd bs=3D1 seek=3D2GiB if=3D/dev/null of=3Dbig =20 @noindent has an apparent size of 2 GiB, yet on most modern -systems, it actually uses almost no disk space. +file systems, it actually uses almost no space. =20 @item -B @var{size} @itemx --block-size=3D@var{size} @@ -12151,9 +12154,9 @@ Equivalent to @code{--apparent-size --block-size=3D= 1}. @itemx --total @opindex -c @opindex --total -@cindex grand total of disk space +@cindex grand total of file system space Print a grand total of all arguments after all arguments have -been processed. This can be used to find out the total disk usage of +been processed. This can be used to find out the total file system usag= e of a given set of files or directories. =20 @item -D @@ -12162,7 +12165,7 @@ a given set of files or directories. @opindex --dereference-args Dereference symbolic links that are command line arguments. Does not affect other symbolic links. This is helpful for finding -out the disk usage of directories, such as @file{/usr/tmp}, which +out the file system usage of directories, such as @file{/usr/tmp}, which= are often symbolic links. =20 @item -d @var{depth} @@ -12207,7 +12210,7 @@ This option is equivalent to @option{--block-size= =3D1K}. @opindex -L @opindex --dereference @cindex symbolic links, dereferencing in @command{du} -Dereference symbolic links (show the disk space used by the file +Dereference symbolic links (show the file system space used by the file or directory that the link points to instead of the space used by the link). =20 @@ -12231,8 +12234,8 @@ This option is equivalent to @option{--block-size= =3D1M}. @opindex -P @opindex --no-dereference @cindex symbolic links, dereferencing in @command{du} -For each symbolic links encountered by @command{du}, -consider the disk space used by the symbolic link. +For each symbolic link encountered by @command{du}, +consider the file system space used by the symbolic link itself. =20 @item -S @itemx --separate-dirs @@ -12648,7 +12651,7 @@ with @env{TZ}, libc, The GNU C Library Reference = Manual}. @section @command{sync}: Synchronize cached writes to persistent storage= =20 @pindex sync -@cindex synchronize disk and memory +@cindex synchronize file system and memory @cindex Synchronize cached writes to persistent storage =20 @command{sync} synchronizes in memory files or file systems to persisten= t @@ -12660,14 +12663,15 @@ sync [@var{option}] [@var{file}]@dots{} =20 @cindex superblock, writing @cindex inodes, written buffered -@command{sync} writes any data buffered in memory out to disk. This can= +@command{sync} writes any data buffered in memory out to the storage dev= ice. +This can include (but is not limited to) modified superblocks, modified inodes, and delayed reads and writes. This must be implemented by the kernel; The @command{sync} program does nothing but exercise the @code{sync}, @code{syncfs}, @code{fsync}, and @code{fdatasync} system calls. =20 @cindex crashes and corruption -The kernel keeps data in memory to avoid doing (relatively slow) disk +The kernel keeps data in memory to avoid doing (relatively slow) device reads and writes. This improves performance, but if the computer crashes, data may be lost or the file system corrupted as a result. The @command{sync} command instructs the kernel to write @@ -13934,7 +13938,8 @@ wget -O - https://example.com/dvd.iso \ =20 This technique is also useful when you want to make a @emph{compressed} copy of the contents of a pipe. -Consider a tool to graphically summarize disk usage data from @samp{du -= ak}. +Consider a tool to graphically summarize file system usage data from +@samp{du -ak}. For a large hierarchy, @samp{du -ak} can run for a long time, and can easily produce terabytes of data, so you won't want to rerun the command unnecessarily. Nor will you want to save @@ -13945,14 +13950,14 @@ until after you've compressed all of the @comma= nd{du} output: =20 @example du -ak | gzip -9 > /tmp/du.gz -gzip -d /tmp/du.gz | xdiskusage -a +gzip -d /tmp/du.gz | checkspace -a @end example =20 With @command{tee} and process substitution, you start the GUI right away and eliminate the decompression completely: =20 @example -du -ak | tee >(gzip -9 > /tmp/du.gz) | xdiskusage -a +du -ak | tee >(gzip -9 > /tmp/du.gz) | checkspace -a @end example =20 Finally, if you regularly create more than one type of @@ -16858,7 +16863,7 @@ The precise method of calculation of load average= varies somewhat between systems. Some systems calculate it as the average number of runnable processes over the last 1, 5 and 15 minutes, but some systems also include processes in the uninterruptible sleep state (that is, -those processes which are waiting for disk I/O). The Linux kernel +those processes which are waiting for device I/O). The Linux kernel includes uninterruptible processes. =20 @command{uptime} is installed only on platforms with infrastructure @@ -18732,7 +18737,7 @@ $ numfmt --from=3Dauto 1Mi 1048576 @end example =20 -Converting from @samp{SI} to @samp{IEC} scales (e.g. when a harddisk cap= acity is +Converting from @samp{SI} to @samp{IEC} scales (e.g. when a drive's capa= city is advertised as @samp{1TB}, while checking the drive's capacity gives lowe= r values): =20 @@ -19129,7 +19134,7 @@ Hopefully, you are familiar with the basics of I/= O redirection in the shell, in particular the concepts of ``standard input,'' ``standard outp= ut,'' and ``standard error''. Briefly, ``standard input'' is a data source, w= here data comes from. A program should not need to either know or care if th= e -data source is a disk file, a keyboard, a magnetic tape, or even a punch= ed +data source is a regular file, a keyboard, a magnetic tape, or even a pu= nched card reader. Similarly, ``standard output'' is a data sink, where data = goes to. The program should neither know nor care where this might be. Programs that only read their standard input, do something to the data, diff --git a/init.cfg b/init.cfg index f1b35d36e..714854648 100644 --- a/init.cfg +++ b/init.cfg @@ -619,7 +619,8 @@ mkfifo_or_skip_() if ! mkfifo "$1"; then # Make an exception of this case -- usually we interpret framework-c= reation # failure as a test failure. However, in this case, when running on= a SunOS - # system using a disk NFS mounted from OpenBSD, the above fails like= this: + # system using a file system NFS mounted from OpenBSD, the above fai= ls like + # this: # mkfifo: cannot make fifo 'fifo-10558': Not owner skip_ 'unable to create a fifo' fi diff --git a/man/df.x b/man/df.x index cc2dd9e1c..28214674b 100644 --- a/man/df.x +++ b/man/df.x @@ -4,20 +4,20 @@ '\" of the GNU General Public License . '\" There is NO WARRANTY, to the extent permitted by law. [NAME] -df \- report file system disk space usage +df \- report file system space usage [DESCRIPTION] This manual page documents the GNU version of .BR df . .B df -displays the amount of disk space available on the file system +displays the amount of space available on the file system containing each file name argument. If no file name is given, the -space available on all currently mounted file systems is shown. Disk -space is shown in 1K blocks by default, unless the environment +space available on all currently mounted file systems is shown. +Space is shown in 1K blocks by default, unless the environment variable POSIXLY_CORRECT is set, in which case 512-byte blocks are used. .PP -If an argument is the absolute file name of a disk device node containin= g a +If an argument is the absolute file name of a device node containing a mounted file system, .B df shows the space available on that file system rather than on the diff --git a/src/copy.c b/src/copy.c index 05b4d4acb..cb9018f93 100644 --- a/src/copy.c +++ b/src/copy.c @@ -2616,7 +2616,7 @@ copy_internal (char const *src_name, char const *ds= t_name, /* If this directory has been copied before during the recursion, there is a symbolic link to an ancestor directory of the symbolic link. It is impossible to - continue to copy this, unless we've got an infinite disk. */ + continue to copy this, unless we've got an infinite file system= =2E */ =20 if (is_ancestor (&src_sb, ancestors)) { diff --git a/src/copy.h b/src/copy.h index a97089137..68d52e1ce 100644 --- a/src/copy.h +++ b/src/copy.h @@ -41,7 +41,7 @@ enum Sparse_type create a corresponding hole in DEST. There is a performance penalt= y here because CP has to search for holes in SRC. But if the holes a= re big enough, that penalty can be offset by the decrease in the amoun= t - of data written to disk. */ + of data written to the file system. */ SPARSE_ALWAYS }; =20 diff --git a/src/dd.c b/src/dd.c index 06be4b04e..6b095982f 100644 --- a/src/dd.c +++ b/src/dd.c @@ -1230,7 +1230,7 @@ iwrite (int fd, char const *buf, size_t size) invalidate_cache (STDOUT_FILENO, 0); =20 /* Attempt to ensure that that final block is committed - to disk as quickly as possible. */ + to stable storage as quickly as possible. */ conversions_mask |=3D C_FSYNC; =20 /* After the subsequent fsync we'll call invalidate_cache @@ -2112,7 +2112,7 @@ dd_copy (void) extra two bytes. */ =20 /* Some devices require alignment on a sector or page boundary - (e.g. character disk devices). Align the input buffer to a + (e.g. character flash or disk devices). Align the input buffer to = a page boundary to cover all bases. Note that due to the swab algorithm, we must have at least one byte in the page before the input buffer; thus we allocate 2 pages of slop in the @@ -2120,8 +2120,8 @@ dd_copy (void) =20 The page alignment is necessary on any Linux kernel that supports either the SGI raw I/O patch or Steven Tweedies raw I/O patch. - It is necessary when accessing raw (i.e., character special) disk - devices on Unixware or other SVR4-derived system. */ + It is necessary when accessing raw (i.e., character special) + storage devices on SVR4-derived systems. */ =20 if (skip_records !=3D 0 || skip_bytes !=3D 0) { diff --git a/src/df.c b/src/df.c index 927365cfa..4534935f5 100644 --- a/src/df.c +++ b/src/df.c @@ -1,4 +1,4 @@ -/* df - summarize free disk space +/* df - summarize free file system space Copyright (C) 1991-2021 Free Software Foundation, Inc. =20 This program is free software: you can redistribute it and/or modify @@ -83,7 +83,7 @@ static bool file_systems_processed; =20 /* If true, invoke the 'sync' system call before getting any usage data.= Using this option can make df very slow, especially with many or very= - busy disks. Note that this may make a difference on some systems -- + busy file systems. This may make a difference on some systems -- SunOS 4.1.3, for one. It is *not* necessary on GNU/Linux. */ static bool require_sync; =20 @@ -986,23 +986,23 @@ add_to_grand_total (struct field_values_t *bv, stru= ct field_values_t *iv) bv->negate_available); } =20 -/* Obtain a space listing for the disk device with absolute file name DI= SK. +/* Obtain a space listing for the device with absolute file name DEVICE.= If MOUNT_POINT is non-NULL, it is the name of the root of the - file system on DISK. + file system on DEVICE. If STAT_FILE is non-null, it is the name of a file within the file system that the user originally asked for; this provides better diagnostics, and sometimes it provides better results on networked file systems that give different free-space results depending on where in the file system you probe. - If FSTYPE is non-NULL, it is the type of the file system on DISK. - If MOUNT_POINT is non-NULL, then DISK may be NULL -- certain systems = may + If FSTYPE is non-NULL, it is the type of the file system on DEVICE. + If MOUNT_POINT is non-NULL, then DEVICE may be NULL -- certain system= s may not be able to produce statistics in this case. ME_DUMMY and ME_REMOTE are the mount entry flags. Caller must set PROCESS_ALL to true when iterating over all entries, = as when df is invoked with no non-option argument. See below for detail= s. */ =20 static void -get_dev (char const *disk, char const *mount_point, char const* file, +get_dev (char const *device, char const *mount_point, char const* file, char const *stat_file, char const *fstype, bool me_dummy, bool me_remote, const struct fs_usage *force_fsu, @@ -1027,12 +1027,12 @@ get_dev (char const *disk, char const *mount_poin= t, char const* file, It would be better to report on the unmounted file system, but statfs doesn't do that on most systems. */ if (!stat_file) - stat_file =3D mount_point ? mount_point : disk; + stat_file =3D mount_point ? mount_point : device; =20 struct fs_usage fsu; if (force_fsu) fsu =3D *force_fsu; - else if (get_fs_usage (stat_file, disk, &fsu)) + else if (get_fs_usage (stat_file, device, &fsu)) { /* If we can't access a system provided entry due to it not being present (now), or due to permissions, @@ -1064,7 +1064,7 @@ get_dev (char const *disk, char const *mount_point,= char const* file, if (stat (stat_file, &sb) =3D=3D 0) { struct mount_entry const * dev_me =3D me_for_dev (sb.st_dev); - if (dev_me && ! STREQ (dev_me->me_devname, disk) + if (dev_me && ! STREQ (dev_me->me_devname, device) && (! dev_me->me_remote || ! me_remote)) { fstype =3D "-"; @@ -1083,13 +1083,13 @@ get_dev (char const *disk, char const *mount_poin= t, char const* file, =20 alloc_table_row (); =20 - if (! disk) - disk =3D "-"; /* unknown */ + if (! device) + device =3D "-"; /* unknown */ =20 if (! file) file =3D "-"; /* unspecified */ =20 - char *dev_name =3D xstrdup (disk); + char *dev_name =3D xstrdup (device); char *resolved_dev; =20 /* On some systems, dev_name is a long-named symlink like @@ -1280,20 +1280,20 @@ last_device_for_mount (char const* mount) return NULL; } =20 -/* If DISK corresponds to a mount point, show its usage +/* If DEVICE corresponds to a mount point, show its usage and return true. Otherwise, return false. */ static bool -get_disk (char const *disk) +get_device (char const *device) { struct mount_entry const *me; struct mount_entry const *best_match =3D NULL; bool best_match_accessible =3D false; bool eclipsed_device =3D false; - char const *file =3D disk; + char const *file =3D device; =20 - char *resolved =3D canonicalize_file_name (disk); + char *resolved =3D canonicalize_file_name (device); if (resolved && IS_ABSOLUTE_FILE_NAME (resolved)) - disk =3D resolved; + device =3D resolved; =20 size_t best_match_len =3D SIZE_MAX; for (me =3D mount_list; me; me =3D me->me_next) @@ -1304,7 +1304,7 @@ get_disk (char const *disk) if (canon_dev && IS_ABSOLUTE_FILE_NAME (canon_dev)) devname =3D canon_dev; =20 - if (STREQ (disk, devname)) + if (STREQ (device, devname)) { char *last_device =3D last_device_for_mount (me->me_mountdir);= eclipsed_device =3D last_device && ! STREQ (last_device, devna= me); @@ -1313,10 +1313,10 @@ get_disk (char const *disk) if (! eclipsed_device && (! best_match_accessible || len < best_match_len)) { - struct stat disk_stats; + struct stat device_stats; bool this_match_accessible =3D false; =20 - if (stat (me->me_mountdir, &disk_stats) =3D=3D 0) + if (stat (me->me_mountdir, &device_stats) =3D=3D 0) best_match_accessible =3D this_match_accessible =3D true= ; =20 if (this_match_accessible @@ -1361,12 +1361,12 @@ get_disk (char const *disk) } =20 /* Figure out which device file or directory POINT is mounted on - and show its disk usage. + and show its device usage. STATP must be the result of 'stat (POINT, STATP)'. */ static void get_point (char const *point, const struct stat *statp) { - struct stat disk_stats; + struct stat device_stats; struct mount_entry *me; struct mount_entry const *best_match =3D NULL; =20 @@ -1398,8 +1398,8 @@ get_point (char const *point, const struct stat *st= atp) } free (resolved); if (best_match - && (stat (best_match->me_mountdir, &disk_stats) !=3D 0 - || disk_stats.st_dev !=3D statp->st_dev)) + && (stat (best_match->me_mountdir, &device_stats) !=3D 0 + || device_stats.st_dev !=3D statp->st_dev)) best_match =3D NULL; =20 if (! best_match) @@ -1407,8 +1407,8 @@ get_point (char const *point, const struct stat *st= atp) { if (me->me_dev =3D=3D (dev_t) -1) { - if (stat (me->me_mountdir, &disk_stats) =3D=3D 0) - me->me_dev =3D disk_stats.st_dev; + if (stat (me->me_mountdir, &device_stats) =3D=3D 0) + me->me_dev =3D device_stats.st_dev; else { /* Report only I/O errors. Other errors might be @@ -1430,8 +1430,8 @@ get_point (char const *point, const struct stat *st= atp) && (!best_match || best_match->me_dummy || !me->me_dummy)) { /* Skip bogus mtab entries. */ - if (stat (me->me_mountdir, &disk_stats) !=3D 0 - || disk_stats.st_dev !=3D me->me_dev) + if (stat (me->me_mountdir, &device_stats) !=3D 0 + || device_stats.st_dev !=3D me->me_dev) me->me_dev =3D (dev_t) -2; else best_match =3D me; @@ -1458,14 +1458,14 @@ get_point (char const *point, const struct stat *= statp) } } =20 -/* Determine what kind of node NAME is and show the disk usage +/* Determine what kind of node NAME is and show the device usage for it. STATP is the results of 'stat' on NAME. */ =20 static void get_entry (char const *name, struct stat const *statp) { if ((S_ISBLK (statp->st_mode) || S_ISCHR (statp->st_mode)) - && get_disk (name)) + && get_device (name)) return; =20 get_point (name, statp); diff --git a/src/du.c b/src/du.c index efd519706..343f2e990 100644 --- a/src/du.c +++ b/src/du.c @@ -1,4 +1,4 @@ -/* du -- summarize disk usage +/* du -- summarize device usage Copyright (C) 1988-2021 Free Software Foundation, Inc. =20 This program is free software: you can redistribute it and/or modify @@ -130,7 +130,7 @@ struct dulevel /* If true, display counts for all files, not just directories. */ static bool opt_all =3D false; =20 -/* If true, rather than using the disk usage of each file, +/* If true, rather than using the device usage of each file, use the apparent size (a la stat.st_size). */ static bool apparent_size =3D false; =20 @@ -287,7 +287,7 @@ Usage: %s [OPTION]... [FILE]...\n\ or: %s [OPTION]... --files0-from=3DF\n\ "), program_name, program_name); fputs (_("\ -Summarize disk usage of the set of FILEs, recursively for directories.\n= \ +Summarize device usage of the set of FILEs, recursively for directories.= \n\ "), stdout); =20 emit_mandatory_arg_note (); @@ -295,7 +295,7 @@ Summarize disk usage of the set of FILEs, recursively= for directories.\n\ fputs (_("\ -0, --null end each output line with NUL, not newline\n\ -a, --all write counts for all files, not just directories= \n\ - --apparent-size print apparent sizes, rather than disk usage; al= though\ + --apparent-size print apparent sizes rather than device usage; a= lthough\ \n\ the apparent size is usually smaller, it may b= e\n\ larger due to holes in ('sparse') files, inter= nal\n\ @@ -315,7 +315,7 @@ Summarize disk usage of the set of FILEs, recursively= for directories.\n\ --summarize\n\ "), stdout); fputs (_("\ - --files0-from=3DF summarize disk usage of the\n\ + --files0-from=3DF summarize device usage of the\n\ NUL-terminated file names specified in file F;= \n\ if F is -, then read names from standard input= \n\ -H equivalent to --dereference-args (-D)\n\ diff --git a/src/factor.c b/src/factor.c index 62a269fcf..c2bf05526 100644 --- a/src/factor.c +++ b/src/factor.c @@ -65,7 +65,8 @@ from a prime. We might instead compute the inverse on-the-fly. =20 * Tune trial division table size (not forgetting that this is a stan= dalone - program where the table will be read from disk for each invocation= ). + program where the table will be read from secondary storage for + each invocation). =20 * Implement less naive powm, using k-ary exponentiation for k =3D 3 = or perhaps k =3D 4. diff --git a/src/ioblksize.h b/src/ioblksize.h index 98d46eaa8..5d359d642 100644 --- a/src/ioblksize.h +++ b/src/ioblksize.h @@ -59,7 +59,7 @@ =20 Note that this is to minimize system call overhead. Other values may be appropriate to minimize file system - or disk overhead. For example on my current GNU/Linux system + overhead. For example on my current GNU/Linux system the readahead setting is 128KiB which was read using: =20 file=3D"." diff --git a/src/ls.c b/src/ls.c index b2e753dc8..03ab2f797 100644 --- a/src/ls.c +++ b/src/ls.c @@ -5477,7 +5477,7 @@ Sort entries alphabetically if none of -cftuvSUX no= r --sort is specified.\n\ \n\ "), stdout); fputs (_("\ - -k, --kibibytes default to 1024-byte blocks for disk usage;= \n\ + -k, --kibibytes default to 1024-byte blocks for file system= usage;\n\ used only with -s and per directory total= s\n\ "), stdout); fputs (_("\ diff --git a/src/ptx.c b/src/ptx.c index c488b1192..85c26aa1d 100644 --- a/src/ptx.c +++ b/src/ptx.c @@ -2024,7 +2024,7 @@ main (int argc, char **argv) { BLOCK *text_buffer =3D text_buffers + file_index; =20 - /* Read the file in core, then study it. */ + /* Read the file contents into memory, then study it. */ =20 swallow_file_in_memory (input_file_name[file_index], text_buffer);= find_occurs_in_text (file_index); diff --git a/src/shred.c b/src/shred.c index 7a8d38e76..ca7835512 100644 --- a/src/shred.c +++ b/src/shred.c @@ -203,7 +203,7 @@ and those files usually should not be removed.\n\ The optional HOW parameter indicates how to remove a directory entry:\n\= 'unlink' =3D> use a standard unlink call.\n\ 'wipe' =3D> also first obfuscate bytes in the name.\n\ -'wipesync' =3D> also sync each obfuscated byte to disk.\n\ +'wipesync' =3D> also sync each obfuscated byte to the device.\n\ The default mode is 'wipesync', but note it can be expensive.\n\ \n\ "), stdout); @@ -629,7 +629,7 @@ free_pattern_mem: * The passes start and end with a random pass, and the passes in betwee= n * are done in random order. The idea is to deprive someone trying to * reverse the process of knowledge of the overwrite patterns, so they - * have the additional step of figuring out what was done to the disk + * have the additional step of figuring out what was done to the device * before they can try to reverse or cancel it. * * First, all possible 1-bit patterns. There are two of them. @@ -1018,7 +1018,7 @@ incname (char *name, size_t len) /* * Repeatedly rename a file with shorter and shorter names, * to obliterate all traces of the file name (and length) on any system - * that adds a trailing delimiter to on-disk file names and reuses + * that adds a trailing delimiter to on-device file names and reuses * the same directory slot. Finally, unlink it. * The passed-in filename is modified in place to the new filename. * (Which is unlinked if this function succeeds, but is still present if= diff --git a/src/sort.c b/src/sort.c index 451bfe08a..cba809c33 100644 --- a/src/sort.c +++ b/src/sort.c @@ -132,7 +132,7 @@ enum { /* The number of times we should try to fork a compression process (we retry if the fork call fails). We don't _need_ to compress - temp files, this is just to reduce disk access, so this number + temp files, this is just to reduce file system access, so this nu= mber can be small. Each retry doubles in duration. */ MAX_FORK_TRIES_COMPRESS =3D 4, =20 @@ -171,7 +171,7 @@ enum blanktype { bl_start, bl_end, bl_both }; /* The character marking end of line. Default to \n. */ static char eolchar =3D '\n'; =20 -/* Lines are held in core as counted strings. */ +/* Lines are held in memory as counted strings. */ struct line { char *text; /* Text of the line. */ @@ -3036,7 +3036,7 @@ mergefps (struct sortfile *files, size_t ntemps, si= ze_t nfiles, else write_line (smallest, ofp, output_file); =20 - /* Check if we need to read more lines into core. */ + /* Check if we need to read more lines into memory. */ if (base[ord[0]] < smallest) cur[ord[0]] =3D smallest - 1; else diff --git a/src/system.h b/src/system.h index ce264b121..3a914965f 100644 --- a/src/system.h +++ b/src/system.h @@ -365,7 +365,7 @@ enum /* Define away proper_name (leaving proper_name_utf8, which affects far fewer programs), since it's not worth the cost of adding ~17KB to the x86_64 text size of every single program. This avoids a 40% - (almost ~2MB) increase in the on-disk space utilization for the set + (almost ~2MB) increase in the file system space utilization for the s= et of the 100 binaries. */ #define proper_name(x) (x) =20 diff --git a/src/tsort.c b/src/tsort.c index 33b3419c0..de4582303 100644 --- a/src/tsort.c +++ b/src/tsort.c @@ -49,7 +49,7 @@ struct successor struct successor *next; }; =20 -/* Each string is held in core as the head of a list of successors. */ +/* Each string is held in memory as the head of a list of successors. *= / struct item { char const *str; diff --git a/tests/cp/sparse-extents.sh b/tests/cp/sparse-extents.sh index 1e9156149..8f5b68653 100755 --- a/tests/cp/sparse-extents.sh +++ b/tests/cp/sparse-extents.sh @@ -36,7 +36,7 @@ if false; then # Require more space than we'll actually use, so that # tests run in parallel do not run out of space. # Otherwise, with inadequate space, simply running the following -# fallocate command would induce a temporary disk-full condition, +# fallocate command would induce a temporary file-system-full condition,= # which would cause failure of unrelated tests run in parallel. require_file_system_bytes_free_ 800000000 =20 diff --git a/tests/df/df-P.sh b/tests/df/df-P.sh index 3fac6c2f9..7441c6446 100755 --- a/tests/df/df-P.sh +++ b/tests/df/df-P.sh @@ -23,7 +23,7 @@ print_ver_ df df -P . > t1 || fail=3D1 BLOCK_SIZE=3D1M df -P . > t2 || fail=3D1 =20 -# Since disk utilization may be changing, compare only df's header line.= +# Since file system utilization may be changing, compare only df's heade= r line. # That records the block size. E.g., for "1M", it would be: # Filesystem 1048576-blocks Used Available Capacity Mounted= on # while for 1K, it would be diff --git a/tests/df/df-symlink.sh b/tests/df/df-symlink.sh index f15c0bd09..a2b812597 100755 --- a/tests/df/df-symlink.sh +++ b/tests/df/df-symlink.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Ensure that df dereferences symlinks to disk nodes +# Ensure that df dereferences symlinks to file system nodes =20 # Copyright (C) 2013-2021 Free Software Foundation, Inc. =20 @@ -19,12 +19,13 @@ . "${srcdir=3D.}/tests/init.sh"; path_prepend_ ./src print_ver_ df =20 -disk=3D$(df --out=3Dsource '.' | tail -n1) || +file_system=3D$(df --out=3Dsource '.' | tail -n1) || skip_ "cannot determine '.' file system" =20 -ln -s "$disk" symlink || framework_failure_ +ln -s "$file_system" symlink || framework_failure_ =20 -df --out=3Dsource,target "$disk" > exp || skip_ "cannot get info for $di= sk" +df --out=3Dsource,target "$file_system" > exp || + skip_ "cannot get info for $file_system" df --out=3Dsource,target symlink > out || fail=3D1 compare exp out || fail=3D1 =20 @@ -34,7 +35,7 @@ compare exp out || fail=3D1 # I.e., '.' =3D> /dev/mapper/fedora-home -> /dev/dm-2 # Restrict this test to systems with a 1:1 mapping between # source and target. This excludes for example BTRFS sub-volumes. -if test "$(df --output=3Dsource | grep -F "$disk" | wc -l)" =3D 1; then +if test "$(df --output=3Dsource | grep -F "$file_system" | wc -l)" =3D 1= ; then df --out=3Dsource,target '.' > out || fail=3D1 compare exp out || fail=3D1 fi diff --git a/tests/du/8gb.sh b/tests/du/8gb.sh index 230dd4e30..cfa13c1d7 100755 --- a/tests/du/8gb.sh +++ b/tests/du/8gb.sh @@ -29,7 +29,7 @@ because file offsets are only 32 bits on this file syst= em' fi =20 # FIXME: this should be a test of dd. -# On some systems (at least linux-2.4.18 + NFS to disks on a Solaris sys= tem) +# On some systems (at least linux-2.4.18 + NFS to Solaris system) # the 'dd' command above mistakenly creates a file of length '0', yet # doesn't fail. The root of that failure is that the ftruncate call # returns zero but doesn't do its job. Detect this failure. diff --git a/tests/du/basic.sh b/tests/du/basic.sh index 162587b88..491d7a9ef 100755 --- a/tests/du/basic.sh +++ b/tests/du/basic.sh @@ -23,7 +23,7 @@ mkdir -p a/b d d/sub || framework_failure_ =20 # Ensure that these files contain more than 64 bytes, so that we don't # immediately disqualify file systems (e.g., NetApp) on which smaller -# files take up zero disk blocks. +# files take up zero file system blocks. printf '%*s' 257 make-sure-the-file-is-non-empty > a/b/F || framework_fa= ilure_ printf %4096s x > d/1 cp d/1 d/sub/2 diff --git a/tests/du/deref.sh b/tests/du/deref.sh index 4eeb2104b..c48e7e9f9 100755 --- a/tests/du/deref.sh +++ b/tests/du/deref.sh @@ -36,8 +36,8 @@ du -sD slink b > /dev/null 2>&1 || fail=3D1 # This used to fail to report the dangling symlink. returns_ 1 du -L dangle > /dev/null 2>&1 || fail=3D1 =20 -# du -L used to mess up, either by counting the symlink's disk space its= elf -# (-L should follow symlinks, not count their space) +# du -L used to mess up, either by counting the symlink's file system sp= ace +# itself (-L should follow symlinks, not count their space) # or (briefly in July 2010) by omitting the entry for "a". du_L_output=3D$(du -L a) || fail=3D1 du_lL_output=3D$(du -lL a) || fail=3D1 diff --git a/tests/misc/help-version.sh b/tests/misc/help-version.sh index 17d4c7032..532b60154 100755 --- a/tests/misc/help-version.sh +++ b/tests/misc/help-version.sh @@ -83,7 +83,7 @@ for i in $built_programs; do env $i --help >/dev/null || fail=3D1 env $i --version >/dev/null || fail=3D1 =20 - # Make sure they fail upon 'disk full' error. + # Make sure they fail upon 'file system full' error. if test -w /dev/full && test -c /dev/full; then test $i =3D [ && prog=3Dlbracket || prog=3D$(echo $i|sed "s/$EXEEXT$= //") eval "expected=3D\$expected_failure_status_$prog" diff --git a/tests/other-fs-tmpdir b/tests/other-fs-tmpdir index fbd601201..5f24c6443 100644 --- a/tests/other-fs-tmpdir +++ b/tests/other-fs-tmpdir @@ -45,7 +45,7 @@ done =20 if test -z "$other_partition_tmpdir"; then skip_ \ -"requires a writable directory on a different disk partition, +"requires a writable directory on a different file system, and I couldn't find one. I tried these: $CANDIDATE_TMP_DIRS Set your environment variable CANDIDATE_TMP_DIRS to make diff --git a/tests/rm/ext3-perf.sh b/tests/rm/ext3-perf.sh index 2bbaf6a52..540357e82 100755 --- a/tests/rm/ext3-perf.sh +++ b/tests/rm/ext3-perf.sh @@ -21,7 +21,7 @@ print_ver_ rm =20 very_expensive_ =20 -# Using rm -rf to remove a 400k-entry directory takes: +# In a circa 2008 benchmark, using rm -rf to remove a 400k-entry directo= ry took: # - 9 seconds with the patch, on a 2-yr-old system # - 350 seconds without the patch, on a high-end system (disk 20-30% fas= ter) threshold_seconds=3D60 @@ -32,9 +32,9 @@ n=3D400000 # Choose a value that is large enough to ensure an accidentally # regressed rm would require much longer than $threshold_seconds to remo= ve # the directory. With n=3D400k, pre-patch GNU rm would require about 35= 0 -# seconds even on a fast disk. On a relatively modern system, the +# seconds even on a fast disk. On a circa 2006 system, the # patched version of rm requires about 10 seconds, so even if you -# choose to enable very expensive tests with a disk that is much slower,= +# choose to enable very expensive tests with a device that is much slowe= r, # the test should still succeed. =20 # Skip unless "." is on an ext[34] file system. diff --git a/tests/tail-2/inotify-rotate.sh b/tests/tail-2/inotify-rotate= =2Esh index 030d22a08..555c23cac 100755 --- a/tests/tail-2/inotify-rotate.sh +++ b/tests/tail-2/inotify-rotate.sh @@ -54,7 +54,7 @@ for i in $(seq 50); do rm -f k x out =20 # Normally less than a second is required here, but with heavy load - # and a lot of disk activity, even 20 seconds is insufficient, which= + # and a lot of file system activity, even 20 seconds is insufficient= , which # leads to this timeout killing tail before the "ok" is written belo= w. >k && >x || framework_failure_ failed to initialize files timeout 60 tail $fastpoll -F k > out 2>&1 & pid=3D$! --=20 2.30.2 --------------C358C53B058BF5FCEBDF1D47-- From unknown Fri Aug 15 04:04:36 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 26 Aug 2021 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator