Bug 229806

Summary: usr.sbin/sysrc: Warning message "unknown variable" should be on stderr
Product: Base System Reporter: Andreas Sommer <andreas.sommer87>
Component: binAssignee: Devin Teske <dteske>
Status: Closed FIXED    
Severity: Affects Only Me CC: dteske
Priority: --- Keywords: patch
Version: 11.1-RELEASE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Write warning to stderr none

Description Andreas Sommer 2018-07-16 14:49:11 UTC
Created attachment 195172 [details]
Write warning to stderr

Patch speaks for itself. This hit me when I did a scripted `sysrc -n -f /usr/local/etc/my-config-file my-var` and ended up having an error message in stdout instead of an empty value.
Comment 1 Devin Teske freebsd_committer freebsd_triage 2018-07-16 18:28:17 UTC
Thanks.

Will apply with minor modification -- \\n should be \n (doesn't matter if the shell expands it before passing it to printf or not; either way you get the desired result).
Comment 2 commit-hook freebsd_committer freebsd_triage 2018-07-16 18:53:53 UTC
A commit references this bug:

Author: dteske
Date: Mon Jul 16 18:53:18 UTC 2018
New revision: 336350
URL: https://svnweb.freebsd.org/changeset/base/336350

Log:
  sysrc(8): Send error message to stderr (not stdout)

  PR:		bin/229806
  Reported by:	Andreas Sommer <andreas.sommer87@googlemail.com>
  MFC after:	3 days
  X-MFC-to:	stable/11 stable/10 stable/9
  Sponsored by:	Smule, Inc.

Changes:
  head/usr.sbin/sysrc/sysrc
Comment 3 Andreas Sommer 2018-07-17 05:23:54 UTC
(In reply to Devin Teske from comment #1)
Sure, I don't mind staying consistent in "\n" vs. "\\n" as it does not matter here. Linters like shellcheck, however, explicitly spit out a note at such lines (which is why I usually write it using escaping):

  Backslash is literal in "\n". Prefer explicit escaping: "\\n". [SC1117]
Comment 4 commit-hook freebsd_committer freebsd_triage 2018-08-10 20:08:45 UTC
A commit references this bug:

Author: dteske
Date: Fri Aug 10 20:08:00 UTC 2018
New revision: 337588
URL: https://svnweb.freebsd.org/changeset/base/337588

Log:
  MFC SVN r336350: Send sysrc(8) error message to stderr (not stdout)

  PR:		bin/229806
  Reported by:	Andreas Sommer <andreas.sommer87@googlemail.com>
  Sponsored by:	Smule, Inc.

Changes:
_U  stable/10/
  stable/10/usr.sbin/sysrc/sysrc
_U  stable/11/
  stable/11/usr.sbin/sysrc/sysrc
_U  stable/9/
_U  stable/9/usr.sbin/
_U  stable/9/usr.sbin/sysrc/
  stable/9/usr.sbin/sysrc/sysrc