On Sun, Sep 6, 2009 at 4:24 AM, <Casper.Dik at sun.com> wrote: > > >>This seems to be a direct result of Solaris' insistence that /bin/sh >>or /sbin/sh is the one true shell, even though /bin/ksh (which has >>built-in echo) has been part of the required minimum installation for >>every currently supported release of Solaris. In OpenSolaris, /bin/sh >>and /sbin/sh is now ksh93 (thanks, Roland!) making calls to "echo" >>turn into built-in commands. The performance problem will persist if >>the scripts call /usr/bin/echo or /bin/echo instead of just "echo". > > AFAIK, all the scripts in patch are all ksh scripts.
Consider 139996-02/SUNWcsu/install/i.none: - It has no she-bang line, implying /bin/sh. - At line 73 it defines ECHO="/usr/bin/echo" - Lines 161 - 256 are a while loop that contains... - 191: $ECHO | $SED | nawk - 196: $ECHO | $SED - 198: $ECHO | $SED - 208-209: echo | $SED - 210-211: echo | $SED - 249: $ECHO - 253: echo Some of those $ECHO and echo commands are in if statements, but it seems reasonable to think that half of them get executed. for every file that is installed. I believe that the other <patch>/<pkg>/install/* scripts suffer from the same problems, but they are not called on a per-file basis. Suggestions for improvement: 1. Use "#! /bin/ksh" and fix any code that explicitly calls "/sbin/sh $file". 2. Consistently use $ECHO or echo. If $ECHO, ECHO="echo". 3. Use "echo | awk" instead of "echo | sed | nawk". In my experimentation awk is faster and it can do via sub() or gsub() the same thing that sed is doing in the trivial uses of sed. 4. Consider ${parameter%word} and ${parameter#word} instead of "echo | sed s at word@@". -- Mike Gerdts http://mgerdts.blogspot.com/