Bug 221534

Summary: [patch] pgrep(1) does not print the final newline
Product: Base System Reporter: kd-dev
Component: binAssignee: Lawrence Stewart <lstewart>
Status: Closed FIXED    
Severity: Affects Many People CC: emaste, lstewart
Priority: --- Keywords: patch
Version: CURRENT   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Print a newline before exiting none

Description kd-dev 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 freebsd_triage 2017-08-16 01:50:13 UTC
Thanks for the report. Unintended change in behaviour. Will fix.
Comment 2 commit-hook freebsd_committer freebsd_triage 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 freebsd_triage 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