Troublesed

I’ve been converting some third-party software to Solaris packages(so you can use pkgadd) and Linux RPMS over the last few days. It’s the typical drill; install with the vendor’s install software, bundle up the resulting files, and surround with judiciously-crafted scripts to perform configuration. Then test, test, test.

As part of a postinstall script on Solaris, I have some innocent sed commands that resemble this:

sed -e “s/some_string/${some_environment_variable}/” \
-e “s/another_string/${another_env_variable}/” some_file > some_other_file

And I thought all was well until today. I’d installed the new package on a couple of Solaris systems, and everything worked. I then used those scripts as templates for my Linux %post section for the RPM. I then observed that one of the files operated on by the sed script had multiple instances of some_string on a single line of the input file. The above instructions to sed, in absence of a the “g” modifier, should have replaced only the first instance of some_string. But on Solaris, all instances were replaced, pretty as you please. I even hacked out the sed script, ran it from a shell, and only the first instance was replaced. So it appears the postinstall script handles something differently; it’s called from pkgadd. I am at a loss to explain what’s going on.

Things that work, when they apparently shouldn’t, are as troublesome as things that don’t work, when they apparently should.

-k-

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*