[clug] Next in my series of "how to do things in /bin/sh that you probably shouldn't".
Andrew Janke
a.janke at gmail.com
Wed Aug 19 22:03:10 MDT 2009
> I've spent a little time playing with this - it seems like a nice thing
> to do - and think I've spotted the root cause, which points to the
> answer(s).
>
> <munch nice description of what sh is doing>
>
> IIRC, /bin/sh, spawns processes Right to Left, just an added wrinkle.
<lightbulb!>
AH! this explains why the {} version wasn't working!
I was doing this:
#! /bin/sh
.. stuff ..
# start logging
{
logfile="/tmp/blunketdnuckers.txt"
echo "here is where we do things"
} 2>&1 | tee $logfile
Which now that I look at it again is "not optimal"... What I should
have had was this:
#! /bin/sh
.. stuff ..
logfile="/tmp/blunketdnuckers.txt"
# start logging
{
echo "here is where we do things"
} 2>&1 | tee $logfile
So there IS an easy way. :) provided you are happy to have a great big
set of braces around everything.
I have learnt many new things today, thanks all for taking the time!
a
PS: one day someone is going to have to remind me why we write #!
/bin/sh and not #!/bin/sh, I remember someone once explaining this to
me but it has since leaked from my brain. And while we are at it, how
about a vote on #! /usr/bin/perl as compared to #! /usr/bin/env perl
:) Myself I prefer the latter, but I have found it to be a heated
debate before...
More information about the linux
mailing list