From owner-freebsd-current@freebsd.org Mon Mar 8 20:55:55 2021 Return-Path: Delivered-To: freebsd-current@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A5FF4557C4C for ; Mon, 8 Mar 2021 20:55:55 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound2j.ore.mailhop.org (outbound2j.ore.mailhop.org [54.148.113.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4DvVx71Srhz3khX for ; Mon, 8 Mar 2021 20:55:54 +0000 (UTC) (envelope-from ian@freebsd.org) ARC-Seal: i=1; a=rsa-sha256; t=1615236954; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=IqrMg/xbpz81NJnMzDab/tQPUE5UC6wUfFGLFtvycp5jz/F9Lj5tHMBoVzhGM/wSYUnndO55i+c9D jh1mtvZ8IhOZkF+mN9T6asrAA+twodOocdz86sACdemZzXzqb5Gj0feZHb6y9cZKij8kdcWbooTnPj +pqsj/YMmiAKd4R72awU+DfnEfVsW4/awRvbbGXcr28DTdXooJOllQqa6gzYqLMN8tyGAZ78ELUvaZ EXo6su4b7bCOYeNueDXQVMiXnakCDwdlAtW7QqYX6NS1Zny+j8LDQjlHnVTkC0Ca9R4J4Wh200wavx 5Vh6DgIEjPJ0ylTpMad/iqw5LpKfZOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=arc-outbound20181012; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:to:from:subject:message-id:dkim-signature:from; bh=WTmv4J9ExjuHPSlCZmsyq7KQjd854vtRJhfxWGo4l6s=; b=psCZdVRm7hlhjss5DHgqG49Kf6yXWkGHMhHCJ0eMPr3HoOM6mcfRztcCfrsvlZkvSwha8QMs9aKen KSRp0z0CgRd7paSyyCftEkQyHrw8uXboTmhCm3IutLa1CXU/2Mkbgy9PTKVMKzsARx4riRHbqJz28A alYdQYlg11hcdY8mPNOwsqune+ucKCR7DWfq9iK0szFz2LT5V/J4ufwRfIqAAF5Mc0CMTWZQ0eSoT6 OAR00KKQ1+ePA9KqF7DuGBSbFPBR4+n1/r62a51lVahTgp+wkVE2gIt9Ah9iEREACqjZRZ9Siy5MtD lo4fda77ARQ0ErQW139Iq5zp8914k6A== ARC-Authentication-Results: i=1; outbound4.ore.mailhop.org; spf=softfail smtp.mailfrom=freebsd.org smtp.remote-ip=67.177.211.60; dmarc=none header.from=freebsd.org; arc=none header.oldest-pass=0; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=dkim-low; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:to:from:subject:message-id:from; bh=WTmv4J9ExjuHPSlCZmsyq7KQjd854vtRJhfxWGo4l6s=; b=QZ2ITA4xFu/SnsJ5RuUqT9wimAQ6+pf1oMQHT63WpXeKilZt7jG5575MpqhGQUDHiTKKoaGoDpAc6 k2p8C5EEreWtpVEGOT0g8DunMvk0EfxxK/2Y1zHPSxxJODE8/6kHMJCSF1vttHFhZWEvOTliWkdYVI tsGUD4l3ET6dFq0F6Tmm3dT3W4LCvv0U5N4w6dAkUaTeZp0QHQ8k/VO5qHK1zWnUlWkTAFTjF1yvw0 1wi/GOj8kACt9giVc9r4M3skBPvXRW0BJ942qfYRz52SzmtDKzgOd/I1/1sfYqwl4AVkUnRjQT6+hO tf+8uh9toIodUsi2tCjH8tK4jnhfdvg== X-Originating-IP: 67.177.211.60 X-MHO-RoutePath: aGlwcGll X-MHO-User: ab31223f-8050-11eb-ad62-59765e228ffb X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (c-67-177-211-60.hsd1.co.comcast.net [67.177.211.60]) by outbound4.ore.mailhop.org (Halon) with ESMTPSA id ab31223f-8050-11eb-ad62-59765e228ffb; Mon, 08 Mar 2021 20:55:52 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id 128KtqFB076198; Mon, 8 Mar 2021 13:55:52 -0700 (MST) (envelope-from ian@freebsd.org) Message-ID: <8e9983a4243d158789029ec8b16837b35ca4451a.camel@freebsd.org> Subject: Re: Rationalizing sed -i/-I (in-place editing) argument handling From: Ian Lepore To: Ed Maste , FreeBSD Hackers , FreeBSD Current Date: Mon, 08 Mar 2021 13:55:52 -0700 In-Reply-To: References: Content-Type: text/plain; charset="ASCII" X-Mailer: Evolution 3.28.5 FreeBSD GNOME Team Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4DvVx71Srhz3khX X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [0.00 / 15.00]; local_wl_from(0.00)[freebsd.org]; ASN(0.00)[asn:16509, ipnet:54.148.0.0/15, country:US] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Mar 2021 20:55:55 -0000 On Mon, 2021-03-08 at 15:13 -0500, Ed Maste wrote: > A relatively minor but longstanding incompatibility between FreeBSD > and many other systems is the way sed handles backup files for > in-place editing -- sed's -I and -i options. GNU sed and other BSDs > accept an optional argument: -I.bak will save a backup file with a > .bak extension, and -I with no argument will not create a backup > file. > FreeBSD currently accepts either -I.bak or -I .bak to save a backup > with the given extension, and -I "" (an empty argument) to specify no > backup. > > I've been tripped up by this in the past and I know many others have. > Most recently tobik@ filed PR 254091 for this. Now, I think a single > change to make -i/-I to be compatible with other sed implementations > in one step is too much of a POLA violation, but I think it can > reasonably be done in stages: > > 1. Update the man page to indicate that -i/-I should not have a space > between the flag and the extension. This is compatible with current > FreeBSD sed, other BSDs sed, GNU sed, and my proposed changes below. > No backup is still a special case and remains as -I "". > > I've opened https://reviews.freebsd.org/D29128 with proposed man page > changes. > > 2. Continue accepting -I .bak, but emit a warning suggesting the use > of -I.bak instead. > > 3. Change -I/-i to getopt optional arguments, but keep a special case > for -I/-i "". At this point -I .bak becomes invalid as with other > seds, and specifying no backup can be done with either -I "" or -I > with no argument. This relies on an empty argument having no other > sensible interpretation. > > 4. Continue accepting -I "" to specify no backup, but emit a warning > suggesting the use of -I with no argument. > > 5. Retire the special case for -I "". > > These steps could be done over an extended period of time (such as > one > major release to another) - this is most important between steps 2 > and > 3. > > Please let me know what you think, and if there's something I've > missed. > As someone who has to take care of common software that runs on everything from freebsd 8 through -current, I HATE the very idea of this. If we keep whittling away at the backwards compatibility freebsd is so famous for, I'll have abosolutely zero arguments left for why $work shouldn't just switch to the much more popular and better- supported linux. I also hate the idea of requiring no space between -I and its related value. That seems like a huge POLA violation compared to how virtually every other command's options and arguments work. -- Ian