tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: old style tail(1) options and bin/57483



For my personal use and tail, I've arrived at:
	if(argv[0] && argv[1] && (!argv[2] || !argv[3]) &&
	   (*argv[1] == '-' || *argv[1] == '+') &&
	   (*argv[1] != '-' || (*(argv[1] + 1) != 'c' && *(argv[1] + 1) != 'f' && *(argv[1] + 1) != 'r')) && (!argv[2] || *argv[2] != '-')) {
		// V7-style parsing; goto getopt;s on format misuse
	} else
	getopt:
		// normal getopt parsing
which allows the
  tail ±[count][l|c|b][f|r] [file]
usage, so long as it wouldn't otherwise form a valid (or invalid)
standard tail invocation (incl. any of the arguments being --).

You could generalise this to more files but I don't think that's really
useful; skimming through the DCO corpus for "tail \+[0-9lcbfr]" shows
that the vast majority of legacy usages are in the form of tail +5
or tail +5c, with a few also passing a file.

This fully supports Mouse's and RVPs usages and unbreaks the standard
ones.

Attachment: signature.asc
Description: PGP signature



Home | Main Index | Thread Index | Old Index