/ 2006-08-09 14:20:43 +0200
\ Andrew Beekhof:
> On 8/9/06, Horms <[EMAIL PROTECTED]> wrote:
> >David Lee <[EMAIL PROTECTED]> wrote:
> >> If all the above is correct, wouldn't the function be clearer as:
> >>
> >> # copy stdin (text) to FIFO, with surrounding ">>>" and "<<<" marker
> >> lines.
> >> # no args.; no result
> >> ha_clustermsg() {
> >> echo ">>>" >> $HA_FIFO
> >> cat - >> $HA_FIFO
> >> echo "<<<" >> $HA_FIFO
> >> }
> >>
> >> or:
> >> # copy stdin (text) to FIFO, with surrounding ">>>" and "<<<" marker
> >> lines.
> >> # no args.; no result
> >> ha_clustermsg() {
> >> (echo ">>>"; cat -; echo "<<<") >> $HA_FIFO
> >> }
> >>
> >> or similar?
> >>
> >> (Note that the "cat -" could be reduced to "cat". But for clarity I
> >> prefer the "cat -" version, which makes explicit to the maintainers the
> >> intention to use stdin as the data source. Clarity again.)
> >>
> >> Matt; LMB; others: thoughts?
> >
> >Any variation on that theme is fine by me.
> >Any time I see `...` inside a here-doc I start to become squeamish.
> >
> >Actually, for what its worth, I prefer the first version,
> >it seems clear, and newlines are not a scarce resource.
>
> agreed
it may be that the "original" version was done this way to increase the
likelihood for the whole message to get to the fifo as _one_ blob,
relying on the internal buffering of the first of the 'cat's.
doing "echo >> $HA_FIFO; cat >> $FIFO; echo >> $HA_FIFO", the fifo
would be open/write/fflush/close by bash/sh/the commands three times.
doing (echo ; cat ; echo ) >> $FIFO, bash/sh should only open/close it
once, but each of the commands would imply a dup/write/fflush/close,
all making it more likely that concurrent users of that function would
garble each others messages.
but thats just me guessing after doing shell magic since quite a while
with lots of different versions of different shells...
--
: Lars Ellenberg Tel +43-1-8178292-0 :
: LINBIT Information Technologies GmbH Fax +43-1-8178292-82 :
: Schoenbrunner Str. 244, A-1120 Vienna/Europe http://www.linbit.com :
_______________________________________________________
Linux-HA-Dev: [email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/