NetBSD Problem Report #50647

From www@NetBSD.org  Mon Jan 11 15:25:51 2016
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.NetBSD.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 3D4BA7ABC0
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 11 Jan 2016 15:25:51 +0000 (UTC)
Message-Id: <20160111152550.165A97ABF7@mollari.NetBSD.org>
Date: Mon, 11 Jan 2016 15:25:50 +0000 (UTC)
From: imil@home.imil.net
Reply-To: imil@home.imil.net
To: gnats-bugs@NetBSD.org
Subject: "echo -n" in rc.subr breaks the stop command on OSX
X-Send-Pr-Version: www-1.0

>Number:         50647
>Category:       standards
>Synopsis:       "echo -n" in rc.subr breaks the stop command on OSX
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    standards-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jan 11 15:30:00 +0000 2016
>Closed-Date:    Fri Aug 13 21:39:18 +0000 2021
>Last-Modified:  Fri Aug 13 21:39:18 +0000 2021
>Originator:     Emile `iMil' Heitor
>Release:        Mac OSX 10.10
>Organization:
NetBSD
>Environment:
Darwin kressh.home.imil.net 14.5.0 Darwin Kernel Version 14.5.0: Tue Sep  1 21:23:09 PDT 2015; root:xnu-2782.50.1~1/RELEASE_X86_64 x86_64
>Description:
rc.subr uses `echo -n` in various functions, this makes the script not portable under operating systems not supporting echo "-n" flag.
>How-To-Repeat:
Use rc.subr on Mac OSX, try a rc.d script and witness:

/etc/rc.subr: line 706: kill: 29370: invalid signal specification
>Fix:
Simply replace "echo -n" with "printf".

>Release-Note:

>Audit-Trail:
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: standards/50647: "echo -n" in rc.subr breaks the stop command on OSX
Date: Mon, 11 Jan 2016 16:36:18 +0100

 This hardly is a "standards" issue - we are BSD after all ;-)
 (not that I object to the suggested change)

 Martin

From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: standards/50647: "echo -n" in rc.subr breaks the stop command on
 OSX
Date: Mon, 30 May 2016 17:13:51 +0000

 On Mon, Jan 11, 2016 at 03:30:00PM +0000, imil@home.imil.net wrote:
  > rc.subr uses `echo -n` in various functions, this makes the script
  > not portable under operating systems not supporting echo "-n" flag.

 MacOS doesn't support echo -n? What is this, 1992?

 -- 
 David A. Holland
 dholland@netbsd.org

From: Soren Jacobsen <snj@blef.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: standards/50647: "echo -n" in rc.subr breaks the stop command on
 OSX
Date: Wed, 22 Jun 2016 16:50:54 -0700

 On 05/30 17:15, David Holland wrote:
 > The following reply was made to PR standards/50647; it has been noted by GNATS.
 > 
 > From: David Holland <dholland-bugs@netbsd.org>
 > To: gnats-bugs@NetBSD.org
 > Cc: 
 > Subject: Re: standards/50647: "echo -n" in rc.subr breaks the stop command on
 >  OSX
 > Date: Mon, 30 May 2016 17:13:51 +0000
 > 
 >  On Mon, Jan 11, 2016 at 03:30:00PM +0000, imil@home.imil.net wrote:
 >   > rc.subr uses `echo -n` in various functions, this makes the script
 >   > not portable under operating systems not supporting echo "-n" flag.
 >  
 >  MacOS doesn't support echo -n? What is this, 1992?

 2007, more like it.  OS X ships a crusty version of bash (3.2.57) as
 their /bin/sh, presumably because it's the last GPLv2 release.  Blech.
 Anyway, bash 3.2.57 only supports echo -n when invoked as bash, not as
 sh.  Double blech.

 Soren

State-Changed-From-To: open->feedback
State-Changed-By: kre@NetBSD.org
State-Changed-When: Sat, 20 Oct 2018 10:51:58 +0000
State-Changed-Why:
I believe this is fixed in NetBSD current.   Can you confirm?
Note: the fix is in rc.subr, and should apply to most uses of
echo in rc.d/* scripts, but it is possible for a script to
override it, and still use echo -n if it really wants to.
I see none of those in the NetBSD base system rc.d scripts, but ...


From: coypu@sdf.org
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: standards/50647 ("echo -n" in rc.subr breaks the stop command on
 OSX)
Date: Sun, 21 Oct 2018 12:57:30 +0000

 For pkgsrc rc.subr:

 revision 1.12
 date: 2015-05-10 22:20:09 +0300;  author: bsiegert;  state: Exp;  lines:
 +4 -1;  commitid: s0nI24XbPxslXVky;
 Use /bin/echo on Darwin, as the builtin does not have the -n option.
 Bump version.
 Patch from Jason White in PR pkg/49724.

From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: standards/50647 ("echo -n" in rc.subr breaks the stop command on OSX)
Date: Sun, 21 Oct 2018 22:55:17 +0700

     Date:        Sun, 21 Oct 2018 13:00:01 +0000 (UTC)
     From:        coypu@sdf.org
     Message-ID:  <20181021130001.94C477A237@mollari.NetBSD.org>

   | From: coypu@sdf.org
   | To: gnats-bugs@netbsd.org
   | Cc: 
   | Subject: Re: standards/50647 ("echo -n" in rc.subr breaks the stop command on
   |  OSX)
   | Date: Sun, 21 Oct 2018 12:57:30 +0000
   |
   |  For pkgsrc rc.subr:

 pkgsrc rc.subr should probably be updated to be the same as the base
 system rc.subr which no longer (normally) uses echo at all, but iuses
 printf (which is much more standard and predictable, at least with standard
 usages).

 That is echo has been a function in rc.subr for ages, but it then used the
 built in echo, for a while now now it uses printf instead.   This causes all
 normal invocations of echo in rc and rc.d/* to actually use printf.   The
 function handles echo with or without -n.

 kre

State-Changed-From-To: feedback->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Fri, 13 Aug 2021 21:39:18 +0000
State-Changed-Why:
was fixed years ago
while it's true that the pkgsrc rc.subr should be updated from base, that's a
big deal and keeping random related PRs open doesn't help it get done.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.