Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Mar 2019 18:24:17 +0000 (UTC)
From:      Conrad Meyer <cem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r344891 - in head/usr.bin/seq: . tests
Message-ID:  <201903071824.x27IOHWf081148@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: cem
Date: Thu Mar  7 18:24:16 2019
New Revision: 344891
URL: https://svnweb.freebsd.org/changeset/base/344891

Log:
  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

Modified:
  head/usr.bin/seq/seq.c
  head/usr.bin/seq/tests/seq_test.sh

Modified: head/usr.bin/seq/seq.c
==============================================================================
--- head/usr.bin/seq/seq.c	Thu Mar  7 18:12:34 2019	(r344890)
+++ head/usr.bin/seq/seq.c	Thu Mar  7 18:24:16 2019	(r344891)
@@ -310,7 +310,8 @@ valid_format(const char *fmt)
 		}
 	}
 
-	return (conversions <= 1);
+	/* PR 236347 -- user format strings must have a conversion */
+	return (conversions == 1);
 }
 
 /*

Modified: head/usr.bin/seq/tests/seq_test.sh
==============================================================================
--- head/usr.bin/seq/tests/seq_test.sh	Thu Mar  7 18:12:34 2019	(r344890)
+++ head/usr.bin/seq/tests/seq_test.sh	Thu Mar  7 18:24:16 2019	(r344891)
@@ -1,4 +1,4 @@
-# Copyright (c) 2018 Conrad Meyer <cem@FreeBSD.org>
+# Copyright (c) 2019 Conrad Meyer <cem@FreeBSD.org>
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -34,7 +34,22 @@ float_rounding_body()
 	atf_check -o inline:'1\n1.1\n1.2\n' seq 1 0.1 1.2
 }
 
+atf_test_case format_includes_conversion
+format_includes_conversion_head()
+{
+	atf_set "descr" "Check for correct user-provided format strings"
+}
+format_includes_conversion_body()
+{
+	# PR 236347
+	atf_check -s exit:1 -o empty -e match:"invalid format string" \
+	    seq -f foo 3
+	atf_check -s exit:0 -o inline:'foo1\nfoo2\n' -e empty \
+	    seq -f foo%g 2
+}
+
 atf_init_test_cases()
 {
 	atf_add_test_case float_rounding
+	atf_add_test_case format_includes_conversion
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201903071824.x27IOHWf081148>