[LINUX] Future nl command

nl command Advent Calendar 2020 This is the last article. I will summarize the direction of the nl command in the future.

GNU coreutils

coreutils has some features that show some future policy.

What to do in the future

Coreutils - rejected feature requests This page contains a list of rejected features. This is to prevent the same feature request from being posted over and over again, even though it has been decided not to do so. nl does not have a feature that has been rejected in the past.

cat -n

RE: cat -n with different format? Regarding cat -n, it seems that there was a request to change the format of the separator and it was rejected. In response to a request to change the separator to :, the example of awk and grep -n is shown while answering "You can use sed or nl". ~~ There is also an example of nl -s ... ~~

What is planned

TODO There is a file called TODO in the coreutils repository, which summarizes what to do in the future. However, there is no item related to nl.

Discussion on the mailing list

PBRE

nl: add way to exclude matching lines from getting numbered! In a relatively recent feature proposal, an extension called "PBREthat numbers lines where regular expressions do not match" has been proposed for the numbering methodpBRE` that uses regular expressions. .. But (maybe because I threw it on the bug-coreutils mailing list?) I haven't got a reply so far.

In my personal opinion, it's worth expanding because there are overwhelmingly more opportunities to ** exclude only some lines ** from numbering than to number only some lines. I don't think so. However, I am not confident that there is a need for "only some lines".

Other

If you come up with a plan for yourself, there are three functional improvement plans.

Improvement of processing speed

In relation to this article, I think that the slower than cat -n as nl, which specializes in adding line numbers, is a little jeopardized. is. Of course, the short command name and the small number of types are superior, but I feel that the reason for choosing it is a little unattractive.

Maximum value extension

In connection with this article, it seems unlikely that you will be counting large values ​​as line numbers, but supporting large values ​​is for consistency with other coreutils commands. I think it makes sense. With a recent update, bc and factor now use the GNU MP in all environments. MP is an arbitrary precision calculation library that removes the integer maximum constraint unless memory is exhausted. You may try to implement MP using commands such as seq and nl that can be a source of integers.

Logical page invalidation option

In relation to this article, as a result, it became a response to the GNU extension of the -d option, but I wonder if it was actually easier to understand if it was a new independent option. I'm thinking.

*BSD

It seems that the commands have not been improved in BSD including NetBSD.

POSIX

However, from POSIX incompatibility still remains in nl, that will be dealt with before the enhancement.

BusyBox

In BusyBox's nl, the immediate implementation item will be support for" logical pages ". However, the trade-off between "compatibility with rarely used features" and "increased footprint" can be a headache.

Comments in the source

Looking at the source, it seems that there are plans to implement a logical page. It seems to be "not implemented yet".

https://github.com/mirror/busybox/blob/master/coreutils/nl.c

	static const char nl_longopts[] ALIGN1 =
		"body-numbering\0"	Required_argument "b"
	//	"footer-numbering\0"	Required_argument "f" - not implemented yet
	//	"header-numbering\0"	Required_argument "h" - not implemented yet
	//	"section-delimiter\0"	Required_argument "d" - not implemented yet
		"line-increment\0"	Required_argument "i"
	//	"join-blank-lines\0"	Required_argument "l" - not implemented yet
	//	"number-format\0"	Required_argument "n" - not implemented yet
		"no-renumber\0"		No_argument       "p" // no-op so far
		"number-separator\0"	Required_argument "s"
		"starting-line-number\0"Required_argument "v"
		"number-width\0"	Required_argument "w"
	;

Recommended Posts

Future nl command
nl command processing performance
Participate in nl command development
Summary of "nl command Advent Calendar 2020"
Linux command # 4
Linux command # 3
Command memorandum
nkf command
command prompt
sed command
Linux command # 5
command memo
top command
Command memorandum
Command memo
mv command
seq command