Re: ls flag to show number of hard links

2024-04-09 Thread Carl Edquist
On Tue, 9 Apr 2024, Tony Freeman wrote: I seem to recall that some years ago ls -l would show the number of hard links to a file. Yes with "ls -l" it's the first number you see (after the permissions string). Or you can use "stat -c %h filename" to just grab that number specifically. Carl

Re: Modify buffering of standard streams via environment variables (not LD_PRELOAD)?

2024-04-20 Thread Carl Edquist
On Sat, 20 Apr 2024, Zachary Santer wrote: This was actually in RHEL 7. Oh. In that case it might be worth looking into ... I don't know how buffering works when stdout and stderr get redirected to the same pipe. You'd think, whatever it is, it would have to be smart enough to keep them i

Re: Modify buffering of standard streams via environment variables (not LD_PRELOAD)?

2024-04-27 Thread Carl Edquist
uld assume they both get placed into the same block buffer by default. On Sun, 21 Apr 2024, wrotycz wrote: Sat, Apr 20, 2024 at 16:45 Carl Edquist wrote: However, stdout and stderr are still separate streams even if they refer to the same output file/pipe/device, so partial lines are not i

Re: Pair-wise file operation (copy, link)

2024-08-26 Thread Carl Edquist
On Sun, 25 Aug 2024, Yair Lenga wrote: In my case, I have to bulk-move about 2500 files. This is part of a recurring sync job that has to mirror an existing hierarchy into a new hierarchy with different naming rules. It takes no time to create the mapping (even in bash script, case statement

Re: make ls -l dir1 dir2 in the same order as dir1,2 are specified

2021-03-26 Thread Carl Edquist
Try adding -U On Fri, 26 Mar 2021, pengyu...@gmail.com wrote: Hi, When I try `ls -l dir1 dir2`, the order of dir1 and dir2 in the output is not necessarily the same as the input. How to make it the same as the input order? Thanks. -- Regards, Peng

Re: make ls -l dir1 dir2 in the same order as dir1,2 are specified

2021-03-28 Thread Carl Edquist
On Sat, 27 Mar 2021, L A Walsh wrote: On 2021/03/27 12:34, Glenn Golden wrote: $ ls -fl dir1 dir2 will produce what the OP asked for. -- Interesting. How can ls return the files in the order they are on disk? What you want is the '-U' option (same as --sort=none). This will display

submitting contributions

2021-04-07 Thread Carl Edquist
Greetings Coreutils maintainers! I have a few small contributions I am interested to submit to Coreutils. Since I'm new to the list, I'd like to ask if there are any etiquette things I should have in mind going about this. I have read over the HACKING document, but I am still a little fuzzy a

Re: submitting contributions

2021-04-08 Thread Carl Edquist
On Thu, 8 Apr 2021, p...@draigbrady.com wrote: A `git format-patch` attached to an email is easiest to apply and test locally. Generally emails would be more verbose when discussing patches. As for the commits themselves my rule of thumb for the commit message is: reason for change limited t

[PATCH] ls: add --sort=width (-W) option to sort by filename width

2021-04-09 Thread Carl Edquist
ils-vdir.c tac.c ls-ls.c printf.c coreutils.c single-binary.mk tee.c mkdir.c remove.c coreutils.h make-prime-list.c tty.c mknod.c remove.h cu-progs.mk make-prime-list.o who.c nohup.c runcon.c dircolors.c find-mount-point.c yes.c nproc.c stdbuf.c dircolors.h find-mount-point.h blake2 p

Re: [PATCH] ls: add --sort=width (-W) option to sort by filename width

2021-04-15 Thread Carl Edquist
On Fri, 9 Apr 2021, lsatenst...@yahoo.com wrote: > Perhaps FreeBSD would be interested in this enhancement. Sure, why not. The implementation will be different though, as the ls internals are fairly different for the BSDs. (And they'd have to use a short option flag, since they don't have a s

Re: [PATCH] ls: add --sort=width (-W) option to sort by filename width

2021-04-15 Thread Carl Edquist
On Sat, 10 Apr 2021, p...@draigbrady.com wrote: > I've attached two patches ... > > The first adjusts your patch to: > ... > Expand in texinfo that --sort=width is most useful with -C (the default) FWIW i run 'ls -lW' often enough also, to refresh myself of the details of the files with pesk

Re: [PATCH] ls: add --sort=width (-W) option to sort by filename width

2021-04-15 Thread Carl Edquist
Hi all, On Sun, 11 Apr 2021, Jim Meyering wrote: > On Sat, Apr 10, 2021 at 8:22 PM Pádraig Brady wrote: >> I really like how much more concise it makes output in general. > > Nice. I like this new option, too! Who would have thought :-) Glad to hear the positive reception! :) Thank you for acc

Re: [PATCH] ls: add --sort=width (-W) option to sort by filename width

2021-04-15 Thread Carl Edquist
On Thu, 15 Apr 2021, Michael Stone wrote: I think it's a heck of a lot easier to add short options than it is to remove them, and that there are more ideas for things to do than there are letters. I'm on the side of make it a long option. In a few years if it's a commonly used thing with a gro

Re: [PATCH] ls: add --sort=width (-W) option to sort by filename width

2021-04-15 Thread Carl Edquist
On Thu, 15 Apr 2021, p...@draigbrady.com wrote: > On 15/04/2021 14:33, Carl Edquist wrote: >> PS if you are willing to cheat a bit and treat the f->width member as >> "mutable" (modifying it even when f is pointer to const), you could >> simplify things a bi

Re: [PATCH] ls: add --sort=width (-W) option to sort by filename width

2021-04-16 Thread Carl Edquist
Hi Kaz, On Fri, 16 Apr 2021, Kaz Kylheku (Coreutils) wrote: > The multi column output can be done by ... I don't know if you read the original post in this thread, but it contains a brief (but complete) example for doing all this in the shell, and handles arbitrary characters in filenames. Bu

[PATCH] ls: add --files0-from=FILE option

2021-04-19 Thread Carl Edquist
its utility within ls. Any feedback / requests for improvement are of course welcome. Carl -=-=-+-=-=- [1] https://youtu.be/AQvOnDlql5gFrom f47996c749d7f155a10ca0fa8c1976821059ad50 Mon Sep 17 00:00:00 2001 From: Carl Edquist Date: Fri, 10 May 2019 17:05:47 -0500 Subject: [PATCH] ls: a

[PATCH] configure.ac: fix __get_cpuid_count check to catch link failure

2021-05-10 Thread Carl Edquist
s at link time. Would it be more appropriate to use AC_LINK_IFELSE instead of AC_COMPILE_IFELSE ? I tried swapping this out (as in the attached patch), and now it correctly omits the #define for USE_AVX2_WC_LINECOUNT, and wc compiles & links properly. Thanks, CarlFrom 4f7e27ae1745331772a835564f

gnulib update and bits/long-double.h

2021-05-10 Thread Carl Edquist
Hi, (Attn: Paul, involved in the relevant coreutils & gnulib updates) The recent gnulib update in coreutils [1] broke the build for me, since the bits/long-double.h header does not exist on my system. Looks like this has been discussed and fixed in gnulib [2]. At some point maybe consider bum

Re: how to speed up sort for partially sorted input?

2021-08-11 Thread Carl Edquist
On Tue, 10 Aug 2021, Kaz Kylheku (Coreutils) wrote: On 2021-08-07 17:46, Peng Yu wrote: Hi, Suppose that I want to sort an input by column 1 and column 2 (column 1 is of a higher priority than column 2). The input is already sorted by column1. Is there a way to speed up the sort (compare

Re: how to speed up sort for partially sorted input?

2021-08-12 Thread Carl Edquist
On Wed, 11 Aug 2021, pengyu...@gmail.com wrote: Yes, this involves many calls of the coreuils' sort, which is not efficient. Would it make sense to add an option in sort so that sort can sort a partially sorted input in one shot. Might be nice! Not sure how convenient that would be to work i

Re: how to speed up sort for partially sorted input?

2021-08-13 Thread Carl Edquist
On Thu, 12 Aug 2021, Kaz Kylheku (Coreutils) wrote: The solution doesn't exist today, whereas that Gawk program should run even in ten year old installations. For the solution to be useful, it only has to beat the actual sort which you have available today Hi Kaz, The thing is, it seems re

Re: how to speed up sort for partially sorted input?

2021-08-25 Thread Carl Edquist
On Wed, 25 Aug 2021, arthur200...@gmail.com wrote: The current sort algorithm used by coreutils sort(1) is a mergesort, which unfortunately does not pick up cues on partially-sorted input. A relatively well-known algorithm that picks up partial sort order is timsort [...] [1]: https://en.wi

Re: How to count the last line when it does not end with a newline character?

2021-09-07 Thread Carl Edquist
Hi Peng, On Sun, 5 Sep 2021, Peng Yu wrote: I got 1 instead of 2 in the following example. How to count the last even when it does not end with a newline character? Thanks. $ printf 'a\nb'|wc -l 1 Here is a little trick. You can append a newline if/when missing to the end of input with:

Re: Enhancement to SORT command.

2021-09-20 Thread Carl Edquist
Works great with, eg, 'du -sh * | sort -h' Or, well, if you want to be more careful about it, shopt -s dotglob du -sh0 -- * | sort -hz | tr '\0\n' '\n?' On Mon, 20 Sep 2021, Carl Edquist wrote: I think 'sort -h' does just that, though for your input y

Re: Enhancement to SORT command.

2021-09-20 Thread Carl Edquist
I think 'sort -h' does just that, though for your input you'll need to remove the spaces between the numeric part and the units. Eg: $ ( tr -d ' ' | sort -h ) << EOF 100.0 Kb 303 Mb 4.01 Gb 20 Mb EOF 100.0Kb 20Mb 303Mb 4.01Gb Works great with, eg, 'du -sh * | sort -h' Carl On Mon, 20 Sep

Re: new snapshot available: coreutils-8.32.251-7b0db.tar.xz

2021-09-20 Thread Carl Edquist
fix FP in ls/stat-free-color.sh maint: fix sc_space_before_open_paren failure Carl Edquist (2): ls: add --sort=width option to sort by file name width build: fix __get_cpuid_count check to catch link failure Emanuele Giacomelli (1): csplit: fix regex suppression with specific match count

Re: date command is great but could use improvements

2022-05-26 Thread Carl Edquist
Hi David! Looks like Bob gave an excellent, thorough reply. (Thanks Bob!) For fun, a couple details about "counting" caught my eye from your email: On Fri, 20 May 2022, David Chmelik wrote: I'm European-American, programming since 1993, and may recall Monday was first weekday growing up in

Re: date command is great but could use improvements

2022-07-04 Thread Carl Edquist
On Sun, 3 Jul 2022, David Chmelik wrote: On 5/26/22 12:16 PM, Carl Edquist wrote: In the states i am used to Sunday being the first "day of the week", but "weekdays" refer specifically to Monday-Friday, thus even in the states, Monday is the first "weekday" :)

Re: [PATCH] Re: wc --no-total option

2022-09-12 Thread Carl Edquist
On Mon, 12 Sep 2022, Mike Jonkmans wrote: What about only printing the total? With 'wc --total' or 'wc -t'. Maybe just: cat files | wc

Re: [PATCH] tee: Add --pipe-check to allow instantly detecting closed outputs

2022-12-05 Thread Carl Edquist
On Fri, 2 Dec 2022, Carl Edquist wrote: Although tee has multiple outputs, you only need to monitor a single output fd at a time. Because the only case you actually need to catch is when the final valid output becomes a broken pipe. (So I don't think it's necessary to poll(2) all

Re: [PATCH] tee: Add --pipe-check to allow instantly detecting closed outputs

2022-12-06 Thread Carl Edquist
On Tue, 6 Dec 2022, Carl Edquist wrote: (4.) + /* readable event on STDOUT is equivalent to POLLERR, + and implies an error condition on output like broken pipe. */ I know this is what the comment from tail.c says, but is it actually documented to be true somewhere? And on what

Re: [PATCH] tee: Add --pipe-check to allow instantly detecting closed outputs

2022-12-07 Thread Carl Edquist
ning any errors when open for writing.) Beyond that, I revised the select()-based implementation of iopoll() to address my previous comments. Sorry I got my grubby hands all over it. I do hope you'll like it though! :) Cheers, Carl On Tue, 6 Dec 2022, Carl Edquist wrote: (4.)

Re: [PATCH] tee: Add --pipe-check to allow instantly detecting closed outputs

2022-12-10 Thread Carl Edquist
On Fri, 9 Dec 2022, Carl Edquist wrote: A quick note, this check only needs to be done a total of once per output, it shouldn't be done inside iopoll(), which would result in an additional redundant fstat() per read(). Could this be handled by get_next_out? Sure, either in that fun

Re: [PATCH] tee: Add --pipe-check to allow instantly detecting closed outputs

2022-12-10 Thread Carl Edquist
On Fri, 9 Dec 2022, Carl Edquist wrote: On Fri, 9 Dec 2022, Arsen Arsenović wrote: ... Also, i suspect that the pipe_check option can be disabled if the _input_ is a regular file (or block device), since (i think) these always show up as ready for reading. (This check would only need to be

Re: [PATCH] tee: Add --pipe-check to allow instantly detecting closed outputs

2022-12-15 Thread Carl Edquist
grep options are in POSIX (or, at least, in POSIX.1-2017). Thank you both, have a great night. -- Arsen Arsenović From d2a62057cacd25730243c20506edc66a27e3bf0d Mon Sep 17 00:00:00 2001 From: Carl Edquist Date: Thu, 15 Dec 2022 06:10:33 -0600 Subject: [PATCH 1/2] iopoll: broken pipe detection while wai

Re: [PATCH] tee: Add --pipe-check to allow instantly detecting closed outputs

2022-12-15 Thread Carl Edquist
Aaak! Sorry, please disregard the patchset in my previous email. I messed up a rebase I was doing. I am attaching a corrected patchset now. Thanks! Carl On Thu, 15 Dec 2022, Carl Edquist wrote: Hi Pádraig, At your convenience, please see my attached patch set. ... A couple very small

Re: expr shouldn't use spaces

2022-12-20 Thread Carl Edquist
On Mon, 19 Dec 2022, David Chmelik wrote: If the shell arithmetic is not sufficient, then I'd recommend bc(1). Thanks! I was looking for that. I don't know whether bc or calc is better... But, do try out the built-in shell arithmetic, too. (Eg, under "Arithmetic Expansion" and "ARITHMETI

Re: RFE: enable buffering on null-terminated data

2024-03-10 Thread Carl Edquist via GNU coreutils General Discussion
Hi Zack, This sounds like a potentially useful feature (it'd probably belong with a corresponding new buffer mode in setbuf(3)) ... Filenames should be passed between utilities in a null-terminated fashion, because the null byte is the only byte that can't appear within one. Out of curiosi

Re: RFE: enable buffering on null-terminated data

2024-03-11 Thread Carl Edquist via GNU coreutils General Discussion
On Sun, 10 Mar 2024, Zachary Santer wrote: On Sun, Mar 10, 2024 at 4:36 PM Carl Edquist wrote: Out of curiosity, do you have an example command line for your use case? My use for 'stdbuf --output=L' is to be able to run a command within a bash coprocess. Oh, cool, now you&

Re: RFE: enable buffering on null-terminated data

2024-03-14 Thread Carl Edquist via GNU coreutils General Discussion
On Mon, 11 Mar 2024, Zachary Santer wrote: On Mon, Mar 11, 2024 at 7:54 AM Carl Edquist wrote: (In my coprocess management library, I effectively run every coproc with --output=L by default, by eval'ing the output of 'env -i stdbuf -oL env', because most of the time

Re: RFE: enable buffering on null-terminated data

2024-03-20 Thread Carl Edquist via GNU coreutils General Discussion
On Tue, 19 Mar 2024, Zachary Santer wrote: On Tue, Mar 19, 2024 at 1:24 AM Kaz Kylheku wrote: But what tee does is set up _IONBF on its output streams, including stdout. So it doesn't buffer at all. Awesome. Nevermind. Yay! :D And since tee uses fwrite to copy whatever input is availa

Re: Modify buffering of standard streams via environment variables (not LD_PRELOAD)?

2024-04-20 Thread Carl Edquist via GNU coreutils General Discussion
On Thu, 18 Apr 2024, Zachary Santer wrote: On Wed, Mar 20, 2024 at 4:54 AM Carl Edquist wrote: However, if stdbuf's magic env vars are exported in your shell (either by doing a trick like 'export $(env -i stdbuf -oL env)', or else more simply by first starting a new shell w

Re: [PATCH] ls: add --files0-from=FILE option

2021-04-19 Thread Carl Edquist via GNU coreutils General Discussion
On Mon, 19 Apr 2021, Carl Edquist wrote: I'm submitting for your consideration here a patch to add the standard '--files0-from=FILE' option to ls. Oops! Somehow I ended up attaching an old version of the patch - this one includes some cleanups and help output. T

Re: [PATCH] ls: add --files0-from=FILE option

2021-04-21 Thread Carl Edquist via GNU coreutils General Discussion
Hi Berny, On Wed, 21 Apr 2021, Bernhard Voelker wrote: shouldn't it use the 'argv-iter' gnulib module (like du.c and wc.c) instead of directly using the underlying ... +#include "readtokens0.h" I considered this, too! :) I think the short answer is that du and wc don't actually need to k

Re: [PATCH] ls: add --files0-from=FILE option

2021-04-21 Thread Carl Edquist via GNU coreutils General Discussion
On Tue, 20 Apr 2021, p...@draigbrady.com wrote: > One can also implement this functionality with the DSU pattern like: > > nlargest=10 > find . -printf '%s\t%p\0' | > sort -z -k1,1n | tail -z -n"$nlargest" | cut -z -f2 | > xargs -r0 ls -lUd --color=auto -- > > Arguably that's more scalable

Re: [PATCH] ls: add --files0-from=FILE option

2021-04-26 Thread Carl Edquist via GNU coreutils General Discussion
On Wed, 21 Apr 2021, Carl Edquist wrote: Thanks Pádraig for the thoughtful reply! You bring up some good points, which for the sake of interesting discussion i'd like to follow up on also. (Maybe later this week...) So to follow up - i don't have any action items here, just so

Re: [PATCH] tee: Add --pipe-check to allow instantly detecting closed outputs

2022-11-29 Thread Carl Edquist via GNU coreutils General Discussion
Hi all, On Mon, 28 Nov 2022, Arsen Arsenović wrote: Pádraig Brady writes: Trying to understand your use case better, ... The bug we observed is that on occasion, for instance when running with a tty, or with a script that (for some reason) has a pipe on stdin, the tee-based "compiler" wo

Re: [PATCH] tee: Add --pipe-check to allow instantly detecting closed outputs

2022-11-29 Thread Carl Edquist via GNU coreutils General Discussion
shell immediately. Carl On Tue, 29 Nov 2022, Carl Edquist via GNU coreutils General Discussion wrote: Hi all, On Mon, 28 Nov 2022, Arsen Arsenović wrote: Pádraig Brady writes: Trying to understand your use case better, ... The bug we observed is that on occasion, for instance when ru

Re: [PATCH] tee: Add --pipe-check to allow instantly detecting closed outputs

2022-11-29 Thread Carl Edquist via GNU coreutils General Discussion
On Tue, 29 Nov 2022, Pádraig Brady wrote: On 29/11/2022 17:32, Carl Edquist wrote: ... If this kind of detect-broken-output-pipe logic were added to filter utils generally, the above example (with 4 cats) would return to the shell immediately. Right. Thanks for discussing the more

Re: [PATCH] tee: Add --pipe-check to allow instantly detecting closed outputs

2022-11-29 Thread Carl Edquist via GNU coreutils General Discussion
On Tue, 29 Nov 2022, Arsen Arsenović wrote: The issue here isn't the compilers hanging, it's tee living longer than all the compilers do because it's stdin doesn't EOF (it'd be preferable for it to only live as long as the last of the compilers). I can imagine attempting to implement this wit

Re: [PATCH] tee: Add --pipe-check to allow instantly detecting closed outputs

2022-12-02 Thread Carl Edquist via GNU coreutils General Discussion
On Wed, 30 Nov 2022, Arsen Arsenović wrote: Carl Edquist writes: It sounds like one way or another you want to copy your endless but intermittent input to multiple output pipes, but you want to quit as soon as all the output pipes become broken. Precisely. The most important requirement

Re: [PATCH] tee: Add --pipe-check to allow instantly detecting closed outputs

2022-12-02 Thread Carl Edquist via GNU coreutils General Discussion
PS: On Fri, 2 Dec 2022, Carl Edquist wrote: On the topic of implementation - I was thinking more about a general solution for filter utils, and I am thinking the key thing is to provide a replacement (wrapper) for read(2), that polls two fds together (one input and one ouput), with no

Re: [PATCH] tee: Add --pipe-check to allow instantly detecting closed outputs

2022-12-02 Thread Carl Edquist via GNU coreutils General Discussion
On Fri, 2 Dec 2022, Arsen Arsenović wrote: I'm concerned with adding such a behavior change by default still. I can imagine this "lifetime extension" properly having been relied on in the last many decades it has been around for ;) That's fair! :) I'd be curious to hear about a use-case for

Re: [PATCH] tee: Add --pipe-check to allow instantly detecting closed outputs

2022-12-06 Thread Carl Edquist via GNU coreutils General Discussion
Hi Arsen, thanks for your feedback! On Tue, 6 Dec 2022, Arsen Arsenović wrote: The stubborn part of me might say, for platforms that do not natively support poll(2), we could simply leave out support for this feature. If that's not acceptable, we could add a select(2)-based fallback for platf

Re: [PATCH] tee: Add --pipe-check to allow instantly detecting closed outputs

2022-12-08 Thread Carl Edquist via GNU coreutils General Discussion
On Thu, 8 Dec 2022, Arsen Arsenović wrote: Apologies for my absence, Tuesdays and Wednesdays are long workdays for me. No need for apologies - I feel like i am the one who should apologize for my high volume of email to the list. People have lives after all! :) The timing of this thread c

Re: [PATCH] tee: Add --pipe-check to allow instantly detecting closed outputs

2022-12-09 Thread Carl Edquist via GNU coreutils General Discussion
On Fri, 9 Dec 2022, Arsen Arsenović wrote: Similar to the situation here, i was seeing things annoyingly look like they are still 'alive' longer than they ought to be when providing input from the terminal. Huh, I never tried that, honestly. Here is a simple example: exec 3<> /dev/tcp/

Re: [PATCH] tee: Add --pipe-check to allow instantly detecting closed outputs

2022-12-09 Thread Carl Edquist via GNU coreutils General Discussion
Hi Pádraig, Getting back to this portability question: On Fri, 2 Dec 2022, Pádraig Brady wrote: Anyway if it's possible just to use poll(2) (the system one, not the gnulib replacement), that might simplify the portability logic. Yes it would be better to use poll() if possible, and that's

Re: [PATCH] tee: Add --pipe-check to allow instantly detecting closed outputs

2022-12-10 Thread Carl Edquist via GNU coreutils General Discussion
On Fri, 9 Dec 2022, Carl Edquist wrote: On Fri, 9 Dec 2022, Arsen Arsenović wrote: Originally i had imagined (or hoped) that this broken-pipe detection could also be used for sockets (that was how the issue came up for me), but it seems the semantics for sockets are different than for pipes

Re: [PATCH] tee: Add --pipe-check to allow instantly detecting closed outputs

2022-12-12 Thread Carl Edquist via GNU coreutils General Discussion
On Mon, 12 Dec 2022, Arsen Arsenović wrote: Hi Rob, Rob Landley writes: This sort of thing is why I added -i to toybox's "timeout" command: -i Only kill for inactivity (restart timeout when command produces output) It runs the command's stdout through a pipe and does a poll() with the

Re: [PATCH] tee: Add --pipe-check to allow instantly detecting closed outputs

2022-12-12 Thread Carl Edquist via GNU coreutils General Discussion
On Mon, 12 Dec 2022, Arsen Arsenović wrote: Hi Carl, Carl Edquist writes: [2. text/x-diff; 0001-tee-only-fstat-outputs-if-pipe_check-is-active.patch]... [3. text/x-diff; 0002-tee-skip-pipe-checks-if-input-is-always-ready-for-re.patch]... Thanks for writing these, and the other patches

Re: [PATCH] tee: Add --pipe-check to allow instantly detecting closed outputs

2022-12-13 Thread Carl Edquist via GNU coreutils General Discussion
On Tue, 13 Dec 2022, Pádraig Brady wrote: Thanks to both of you for working through the details on this. This does seem like a useful feature, and would be appropriate to add. A summarized patch set would be appreciated at this stage, thanks. Re HAVE_INOTIFY, that's really a proxy for a linux