#2 Detect sed implementation in configure for portability

closed-fixed
Sam Hocevar
None
5
2008-06-20
2008-06-19
coleman kane
No

The sed implementation in GNU varies somewhat from the BSD sed implementation. Here is a patch that provides some detection for the two in configure.ac and also uses macros in the docs/Makefile.am so that we don't assume that sed is named "sed". Particularly, BSD and GNU differ on how -i works.

For GNU:
sed -i 's/regex/replace/' filename

For BSD:
sed -i '' 's/regex/replace/' filename

In BSD, the argument to -i is mandatory, thus must be explicitly specified with an empty string to indicate "in-place editing". For GNU, it is optional, and the empty-string modifier seems to confuse it.

Discussion

  • coleman kane
    coleman kane
    2008-06-19

    Patch to support BSD compatibility and use configure to probe for sed

     
    Attachments
  • Sam Hocevar
    Sam Hocevar
    2008-06-19

    • assigned_to: nobody --> sammy
     
  • Sam Hocevar
    Sam Hocevar
    2008-06-19

    Logged In: YES
    user_id=37415
    Originator: NO

    Thanks for reporting this. I am not fond of the patch because it
    adds a lot of complexity for such a minor feature, so I think I
    will fall back to the temporary file instead. I will keep the
    AC_PATH_TOOL part just in case, though.

     
  • coleman kane
    coleman kane
    2008-06-19

    Logged In: YES
    user_id=11810
    Originator: YES

    I'd still recommend using the $(SED) expansion in the Makefile.am over the literal "sed". This will ensure that sed is appropriately picked by configure, for instance if the desired sed is not named "sed", or if the desired sed is not in the default executable path.

     
  • Sam Hocevar
    Sam Hocevar
    2008-06-20

    • status: open --> closed-fixed
     
  • Sam Hocevar
    Sam Hocevar
    2008-06-20

    Logged In: YES
    user_id=37415
    Originator: NO

    Thanks. Issue is now fixed in SVN HEAD.