Bug 221534 - [patch] pgrep(1) does not print the final newline
Summary: [patch] pgrep(1) does not print the final newline
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Many People
Assignee: Lawrence Stewart
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2017-08-14 22:56 UTC by Keegan Drake H.P.
Modified: 2018-03-03 10:44 UTC (History)
2 users (show)

See Also:


Attachments
Print a newline before exiting (390 bytes, text/x-csrc)
2017-08-14 22:56 UTC, Keegan Drake H.P.
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Keegan Drake H.P. 2017-08-14 22:56:13 UTC
Created attachment 185422 [details]
Print a newline before exiting

After r322210 pgrep(1) no longer prints the final newline.

Output:
	$ sleep 1 & pgrep sleep
	12345$

Expected output:
	$ sleep 1 & pgrep sleep
	12345
	$
Comment 1 Lawrence Stewart freebsd_committer 2017-08-16 01:50:13 UTC
Thanks for the report. Unintended change in behaviour. Will fix.
Comment 2 commit-hook freebsd_committer 2017-08-17 06:37:25 UTC
A commit references this bug:

Author: lstewart
Date: Thu Aug 17 06:36:21 UTC 2017
New revision: 322613
URL: https://svnweb.freebsd.org/changeset/base/322613

Log:
  The r322210 change to pgrep's PID delimiting behaviour causes pgrep's default
  output to not include a trailing new line, which is a potential POLA violation
  for existing consumers. Change pgrep to always emit a trailing new line on
  completion of its output, regardless of the delimeter in use (which technically
  is also a potential POLA violation for existing consumers that rely on the
  pre-r322210 buggy behaviour, but a line has to be drawn somewhere).

  PR:	221534
  Submitted by:	kdrakehp zoho com
  Reported by:	kdrakehp zoho com
  MFC after:	1 week
  X-MFC-with:	r322210

Changes:
  head/bin/pkill/pkill.c
Comment 3 commit-hook freebsd_committer 2018-03-03 10:44:07 UTC
A commit references this bug:

Author: eadler
Date: Sat Mar  3 10:43:42 UTC 2018
New revision: 330324
URL: https://svnweb.freebsd.org/changeset/base/330324

Log:
  MFC r322210,r322613,r322831:

  pgrep naively appends the delimiter to all PIDs including the last
  e.g. "pgrep -d, getty" outputs "1399,1386,1309,1308,1307,1306,1305,1302,"
  Ensure the list is correctly delimited by suppressing the emission of the
  delimiter after the final PID.

  The r322210 change to pgrep's PID delimiting behaviour causes pgrep's default
  output to not include a trailing new line, which is a potential POLA violation
  for existing consumers. Change pgrep to always emit a trailing new line on
  completion of its output, regardless of the delimeter in use (which technically
  is also a potential POLA violation for existing consumers that rely on the
  pre-r322210 buggy behaviour, but a line has to be drawn somewhere).

  Only emit the trailing new line added in r322613 when not operating in quiet
  mode.

  PR:	221534 (r322613)

Changes:
_U  stable/11/
  stable/11/bin/pkill/pkill.c