From owner-freebsd-questions@freebsd.org Sat Mar 6 10:53:23 2021 Return-Path: Delivered-To: freebsd-questions@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 177E5561B19 for ; Sat, 6 Mar 2021 10:53:23 +0000 (UTC) (envelope-from freebsd@twc.com) Received: from p-impout005.msg.pkvw.co.charter.net (p-impout005aa.msg.pkvw.co.charter.net [47.43.26.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Dt1fp1n9sz3k0V for ; Sat, 6 Mar 2021 10:53:21 +0000 (UTC) (envelope-from freebsd@twc.com) Received: from [192.168.1.5] ([74.132.18.25]) by cmsmtp with ESMTPA id IUYcldVuNeKjEIUYdlUfFv; Sat, 06 Mar 2021 10:53:15 +0000 X-Authority-Analysis: v=2.3 cv=ALzgjvLx c=1 sm=1 tr=0 a=6dKv8Xy78h5PIHsve0hi3A==:117 a=6dKv8Xy78h5PIHsve0hi3A==:17 a=IkcTkHD0fZMA:10 a=6I5d2MoRAAAA:8 a=HSDLPEUgxQIAnP4SmsUA:9 a=QEXdDO2ut3YA:10 a=IjZwj45LgO3ly-622nXo:22 a=BPzZvq435JnGatEyYwdK:22 Subject: Re: sed -i empty argument compatibility issue To: freebsd-questions@freebsd.org References: <9178f6c5-631a-c2c2-c6b1-8def94a3397b@dreamchaser.org> From: Steven Friedrich Message-ID: Date: Sat, 6 Mar 2021 05:53:13 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <9178f6c5-631a-c2c2-c6b1-8def94a3397b@dreamchaser.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-CMAE-Envelope: MS4wfFDgCPg7S/tVs4vKUJfYTliLCb8ajIv/AI70Mlzsem84IsrB4UxlbWCkbvlUNiwR86mgEHfewIwx1NtorsX8cVL242hxTUN1VvTkMmBPyZPmXbtjDnid cRm0tH5cEwo1ZuDJPBfKfQ4NY8SErmx7P/y1fV2ylt0n4VD37hYORVbSSNDTu9JRk8oHVxQngy71zQ== X-Rspamd-Queue-Id: 4Dt1fp1n9sz3k0V X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of freebsd@twc.com designates 47.43.26.136 as permitted sender) smtp.mailfrom=freebsd@twc.com X-Spamd-Result: default: False [-3.30 / 15.00]; RCVD_TLS_LAST(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; RWL_MAILSPIKE_VERYGOOD(0.00)[47.43.26.136:from]; FREEMAIL_FROM(0.00)[TWC.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-1.00)[-1.000]; RECEIVED_SPAMHAUS_PBL(0.00)[74.132.18.25:received]; DMARC_NA(0.00)[TWC.com]; R_SPF_ALLOW(-0.20)[+ip4:47.43.26.0/24]; NEURAL_HAM_SHORT(-1.00)[-0.998]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[twc.com]; ASN(0.00)[asn:40294, ipnet:47.43.24.0/21, country:US]; MIME_TRACE(0.00)[0:+]; MAILMAN_DEST(0.00)[freebsd-questions]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Mar 2021 10:53:23 -0000 On 3/5/2021 3:58 PM, Gary Aitken wrote: > I'm trying to come up with a fix for a script in a port which invokes > sed. > The port comes from a linux environment, and the offending line looks > like this: > (This is in a cMake file.) > > COMMAND sed -i "/^# /d" "${outfile}" > > The issue is that linux sed expects the -I or -i extension modifier to > immediately follow the -i.  In the above line, the extension is > deliberately > missing to provide in-place editing. > > fbsd expects the extension to be separated from the -i by whitespace, or > doesn't work properly when it is empty or immediately follows the -i: > > $ !ls > ls -lt temp.tmp* > -rw-------  1 garya  garya  86 Mar  5 13:15 temp.tmp > -rw-------  1 garya  garya  86 Mar  5 13:15 temp.tmp_org > $ sed -ifoo "/^# /d" temp.tmp  (works on both fbsd & linux)) > $ !ls > ls -lt temp.tmp* > -rw-------  1 garya  garya  30 Mar  5 13:48 temp.tmp > -rw-------  1 garya  garya  86 Mar  5 13:15 temp.tmp_org > -rw-------  1 garya  garya  86 Mar  5 13:15 temp.tmpfoo > $ cp -p temp.tmp_org temp.tmp > $ sed -i"" "/^# /d" temp.tmp   (works on linux but not fbsd) > sed: 1: "temp.tmp": undefined label 'emp.tmp' > $ sed -i "" "/^# /d" temp.tmp  (works on fbsd but not linux) > $ !ls > ls -lt temp.tmp* > -rw-------  1 garya  garya  30 Mar  5 13:49 temp.tmp > -rw-------  1 garya  garya  86 Mar  5 13:15 temp.tmp_org > -rw-------  1 garya  garya  86 Mar  5 13:15 temp.tmpfoo > > So fbsd works with '-i ""' but linux requires '-i""' > > Does anyone know a work-around for this problem? > > Gary Yes, the correct "work-around" is to FIX Linux.  Linux is supposed to mimic Unix, FreeBSD IS Unix. > _______________________________________________ > freebsd-questions@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to > "freebsd-questions-unsubscribe@freebsd.org"