Commit graph

18 commits

Author SHA1 Message Date
Pawel Jakub Dawidek eb4d13126d seq(1): Put separator only between the elements.
- Using non-default ('\n') separator will produce an output with the
  separator at the end of the output, eg.

	% echo "[$(seq -s ' ' 0 2)]"
	[0 1 2 ]

- The output should always be followed by a new line character. Currently:

	% seq -s ' ' 0 2
	0 1 2 %

This change makes seq(1) to behave the same way Linux seq(1):

	% echo "[$(seq -s ' ' 0 2)]"
	[0 1 2]

	% seq -s ' ' 0 2
	0 1 2
	%

Approved by:	oshogbo
Differential Revision:	https://reviews.freebsd.org/D43094
2023-12-21 21:54:05 -08:00
Warner Losh 1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Ed Maste 8f8da1bcc7 seq: style(9) cleanup
This is in part for diff reduction with OpenBSD.

Sponsored by:	The FreeBSD Foundation
2023-07-21 10:17:24 -04:00
Ed Maste 5dae8905a5 seq: combine asprintf return value checks
Error handling is identical for all of these failure cases.

Sponsored by:	The FreeBSD Foundation
2023-06-25 19:57:17 -04:00
Ed Maste e54db9a9cc seq: fix check for rounding error/truncation
Based on OpenBSD 30f0fd29ba6c:
> We need to compare the printable version of the last value displayed,
> not the floating point representation.  Otherwise, we may print the
> last value twice.

PR:		271964
Reported by:	Daniel Kolesa
Reviewed by:	yuripv
Obtained from:	OpenBSD
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40601
2023-06-19 11:02:38 -04:00
Warner Losh b61a573019 spdx: The BSD-2-Clause-NetBSD identifier is obsolete, drop -NetBSD
The SPDX folks have obsoleted the BSD-2-Clause-NetBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:04 -06:00
Mariusz Zaborski 6da5e5d649 seq: fix style nits
MFC after:	2 weeks
2022-10-01 12:05:07 +02:00
Mariusz Zaborski 94c4f663ba seq: fix potential NULL ptr reference
asprintf(3) allocates memory, and there isn't any guarantee of success.

MFC after:	2 weeks
Obtained from:  OpenBSD
2022-10-01 12:05:03 +02:00
Conrad Meyer 905fdc3ff1 seq(1): Require user-provided format strings to contain a conversion
This matches GNU seq, for example.

For users that are looking for similar functionality, 'jot -b foo N' will
print 'foo' N times.  See jot(1).

PR:		236347
Reported by:	<y AT maya.st>
Sponsored by:	Dell EMC Isilon
2019-03-07 18:24:16 +00:00
Kyle Evans ad4e78b50a seq(1): Move long_opts up with globals 2018-05-02 01:04:13 +00:00
Kyle Evans a3f2c2feb1 seq(1): Provide some long options
These match GNU seq(1) names where applicable for compatibility purposes.

MFC after:	1 month
2018-04-30 18:55:01 +00:00
Conrad Meyer 3049d4ccc0 seq(1): Consistently include 'last' for non-integers
The source of error is a rounded increment being too large and thus the loop
steps slightly past 'last'.  Perform a final comparison using the formatted
string values (truncated precision) to determine if we still need to print
the 'last' value.

PR:		217149
Submitted by:	Fernando Apesteguía <fernando.apesteguia AT gmail.com>,
		Yuri Pankov <yuripv AT icloud.com> (earlier version)
Reported by:	Martijn Dekker <mcdutchie AT hotmail.com>
Sponsored by:	Dell EMC Isilon
2018-02-27 22:01:40 +00:00
Pedro F. Giffuni 1de7b4b805 various: general adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.
2017-11-27 15:37:16 +00:00
Xin LI bf855dd342 Sync with NetBSD, mainly address NetBSD bug #43355:
Fix valid_format() to be more careful about allowing only valid
printf formats.

Obtained from:	NetBSD
MFC after:	2 weeks
2014-12-18 20:23:19 +00:00
Ed Schouten cfbd8d469b Add missing static keywords to seq(1) 2011-11-06 08:17:05 +00:00
Rebecca Cran b1ce21c6ef Fix typos.
PR:	bin/148894
Submitted by:	olgeni
2010-11-09 10:59:09 +00:00
Xin LI 0a167a9b98 Treat numbers after [Ee] a positive number rather than an invalid
one.
2010-02-20 01:23:15 +00:00
Xin LI 208987a53c Add seq(1), a small utility to generate sequence number.
Obtained from:	NetBSD
MFC after:	3 months
2010-02-19 23:54:12 +00:00