Marc Haber wrote:
> Please consider this patch which will improve FILTERCTRLM behavior.

Could you say a word or two describing in what way this change
improves FILTERCTRLM behavior?  I am guessing but not really sure what
you are intending.

A comment from the "peanut gallery" anyway.

> --- cron-apt.orig     2005-06-20 11:51:43.000000000 +0200
> +++ /usr/sbin/cron-apt        2005-06-25 14:35:33.000000000 +0200
> @@ -430,8 +430,10 @@
>                       umask $UMASK_SAVE
>                   fi
>                   if [ "$FILTERCTRLM" = "true" ]; then
> -                     grep -v "
> -" "$TEMP" > "$FILTER"
> +                     CTRLM="$(echo -e \\r)"

But 'echo -e' is a bashism and does not work with posix standard
shells.  Actually using echo for all but simple strings is amazingly
non-portable.  Please consider using 'printf' instead as that is
standard.  Also the quotes around the $() are not needed.

  CTRLM=$(printf "\r")

But fortunately that is not needed here at all because sed understands
the escape \r natively.

> +                     < "$TEMP" sed "s/.*$CTRLM\(.\+\)/\1/" > "$FILTER"

I think that putting all of the redirections '< "$TEMP"' after the
command to be the most clear and common.  In this case no input
redirection is needed.  And something about that sed just bothers me
but I can't quite put my finger on it.  For one \+ is a GNU sed
extension.  But that is okay.  The '.' does not match newlines so I
*think* this following is equivalent and more clear and I believe it
would work with all sed programs and all shells.

+                       sed "s/.*\r//" "$TEMP" > "$FILTER"

The line that it is matching against might be very, very long.  I
worry that this might cause a large memory spike in the RE engine.
But if I recall correctly .* handles this specially so this is okay.

Since I don't know the exact pattern this is matching against I can't
say for sure if this sed pattern is correct but it seems to me to be
better.

> +                     #grep -v "
> +#" "$TEMP" > "$FILTER"
>                       cp "$FILTER" "$TEMP"
>                   fi
>                   if [ $RET -ne 0 ]; then

Note that I am not commenting upon the patch itself, just the
micro-syntax of 'echo -e' and sed syntax only.

Thanks
Bob


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to