Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 178415 - gcc-config-1.4.0 uses sed -i which fails on BSD
Summary: gcc-config-1.4.0 uses sed -i which fails on BSD
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: All Other
: High normal
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-13 19:36 UTC by Roy Marples (RETIRED)
Modified: 2007-08-12 01:30 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Add extension and remove file (gcc-config-sed.patch,574 bytes, patch)
2007-05-13 19:37 UTC, Roy Marples (RETIRED)
Details | Diff
sed ... -i '' -- file1 file 2 (gcc-config-sed.patch,642 bytes, patch)
2007-05-14 06:27 UTC, Roy Marples (RETIRED)
Details | Diff
sed ... -i '' -- file1 file 2 (gcc-config-sed.patch,641 bytes, patch)
2007-05-14 06:32 UTC, Roy Marples (RETIRED)
Details | Diff
eval sed ... -i '' -- file1 file 2 (gcc-config-sed.patch,658 bytes, patch)
2007-05-14 06:44 UTC, Roy Marples (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Roy Marples (RETIRED) gentoo-dev 2007-05-13 19:36:07 UTC
Basically the -i option requires an extension on some OS's.
Comment 1 Roy Marples (RETIRED) gentoo-dev 2007-05-13 19:37:23 UTC
Created attachment 119139 [details, diff]
Add extension and remove file
Comment 2 SpanKY gentoo-dev 2007-05-13 21:22:38 UTC
why dont you fix BSD sed to not be so pathetic, or start using GNU sed instead of a limited BSD one
Comment 3 Roy Marples (RETIRED) gentoo-dev 2007-05-13 21:48:03 UTC
Seeing as -i isn't in the POSIX spec for sed, it's behaviour isn't exactly standard.

Seeing as you are all about adhering to POSIX atm maybe you should consider dropping the -i option altogether redirecting output to a tmp file and then moving the tmp file over the other one.
Comment 4 SpanKY gentoo-dev 2007-05-13 21:55:44 UTC
i never said -i was in POSIX ... but since -i is used pretty heavily, seems like getting BSD to make it optional can only help other projects
Comment 5 Roy Marples (RETIRED) gentoo-dev 2007-05-14 06:27:36 UTC
Created attachment 119178 [details, diff]
sed ... -i '' -- file1 file 2

(In reply to comment #4)
> i never said -i was in POSIX ... but since -i is used pretty heavily, seems
> like getting BSD to make it optional can only help other projects

Current BSD sed supports the same functionality as GNU sed, it just has a slightly different interface

GNU sed
sed -i -e 's/foo/bar/g' foo

BSD sed
sed -i '' -e 's/foo/bar/g' foo

BSD sed uses getopt and GNU sed uses getopt_long.
The only way of getting them to co-operate that I have found is like so.
sed -e 's/foo/bar/g' -i '' -- foo

Attached is a patch that allows this, + a comment explaining this.
Comment 6 Roy Marples (RETIRED) gentoo-dev 2007-05-14 06:32:57 UTC
Created attachment 119182 [details, diff]
sed ... -i '' -- file1 file 2

Fix patch.
Comment 7 Roy Marples (RETIRED) gentoo-dev 2007-05-14 06:44:50 UTC
Created attachment 119186 [details, diff]
eval sed ... -i '' -- file1 file 2

Dammit, eval is needed in the script - I'm sure it worked without on the commandline.

Should work for sure now.
Comment 8 Roy Marples (RETIRED) gentoo-dev 2007-05-21 13:52:42 UTC
Comment on attachment 119186 [details, diff]
eval sed ... -i '' -- file1 file 2

I just cannot get that to work reliably with either sed, so I guess this is the only option that works on both platforms :/
Comment 9 SpanKY gentoo-dev 2007-08-12 01:30:00 UTC
dostrow gave me access to a GBSD box, so in return i fixed gcc-config :p

it uses gsed when available