On Fri, Jan 07, 2011 at 05:07 -0600, David Champion wrote:
> * On 07 Jan 2011, Yue Wu wrote:
> > On Fri, Jan 07, 2011 at 03:40:12PM +0800, du yang wrote:
> > >
> > > if [ $(date -d "$(date '+%Y-%m-%d')" "+%s") -gt $epoch ]; then
> > >      echo "%4C %Z %{%d.%m.%y} %-15.15F (%?l?%4l&%4c?) %?H?[%H]?%s%"
> > > else
> > >      echo "%4C %Z %{   %H:%M} %-15.15F (%?l?%4l&%4c?) %?H?[%H]?%s%"
> > > fi
> >
> > Must it be bash script? No bash here, it fails the test with sh...
> 
> This is a POSIX sh script, not Bourne, which is why it fails for you.
> Specifically, $(command) is a POSIX construction that is not supported
> by conventional Bourne shells.  You can fix it by replacing this:
> 
> if [ $(date -d "$(date '+%Y-%m-%d')" "+%s") -gt $epoch ]; then
> 
> with this:
> 
> now=`date '+%Y-%m-%d'`
> if [ `date -d "$now" "+%s"` -gt $epoch ]; then
> 
> However, if I'm not mistaken that command still relies on GNU extensions
> to the "date" command.  (Mixing POSIX and GNU is another common
> portability problem in the Linux era.)  Since you appear to be using
> FreeBSD you may have problems with that even after adapting the shell
> syntax.  (In fact I think it's even more confusing.  Where the -d
> option will simply fail on a pure POSIX system, I think it is actually
> a completely different option on BSD, which has its own extensions
> separate from GNU's.)
> 
> Remember that setting $index_format to a piped command means that the
> command is run once each time a message is displayed on your index.  I
> wrote the code to allow $index_format to be a piped command, and as I
> remember the result is *not* cached.  Since the command in this case is
> a shell script, it's actually going to run three commands: sh, date, and
> another date.
> 
> For these reasons -- portability and performance -- I would not use
> shell for this purpose.  I prefer Python, but Perl might be a better
> choice since it typically has a lower startup time.  Naturally for
> performance concerns, C would be the best choice.
> 

You are absolutely correct. Considering performance in mind is always better.

But scripts and languages like java is still very important in computer world.
Because it allows people to accomplish their tasks easily without making any 
seriously mistake like core dump. It hides many system implementation details 
to whom doesn't care it. It frees programmers from memory tuning and it helps 
not-so clever programmers doing thing correctly.

Most cases for people, function is more important than performance. They just 
care working or not. Why Java is so popular in commercial world.. Simply 
because bosses like it.

At last not the least, for researching and system which is 
performance-sensitive, C/C++ is still the best choice.

- du yang
-- 
oooO:::::::::
(..):::::::::
:\.(:::Oooo::
::\_)::(..)::
:::::::)./:::
::::::(_/::::

Reply via email to