Date: Sat, 6 Mar 2021 05:53:13 -0500 From: Steven Friedrich <FreeBSD@TWC.com> To: freebsd-questions@freebsd.org Subject: Re: sed -i empty argument compatibility issue Message-ID: <bf0f8fe6-66c5-43a8-740a-5423ada4dd56@TWC.com> In-Reply-To: <9178f6c5-631a-c2c2-c6b1-8def94a3397b@dreamchaser.org> References: <9178f6c5-631a-c2c2-c6b1-8def94a3397b@dreamchaser.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bf0f8fe6-66c5-43a8-740a-5423ada4dd56>