On Sat, Jun 25, 2005 at 01:36:18PM -0600, Bob Proulx wrote:
> 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.

The package as delivered might generate "good" output on the console,
but in a pipe one sees pretty well that the progress status messages
printed by aptitude still end up in the output:

[16/[EMAIL PROTECTED] sarge]:~$ sudo cron-apt  -i -s | sed 's/[^[:alnum:]]/g' | 
head -n 10
CRON_APT_RUN___etc_cron_apt_config___Sun_Jul__3_21_09_56_UTC_2005
CRON_APT_ACTION__0_update
CRON_APT_LINE__update__o_quiet_2
_Reading_Package_Lists____0___Reading_Package_Lists____100___Reading_Package_Lists____Done_
_Building_Dependency_Tree____0___Building_Dependency_Tree____0___Building_Dependency_Tree____50___Building_Dependency_Tree____50___Building_Dependency_Tree________
_Reading_extended_state_information____0___Reading_extended_state_information____0___Reading_extended_state_information_______
_Initializing_package_states____0____Initializing_package_states____Done_
_Writing_extended_state_information____0___Writing_extended_state_information____0___Writing_extended_state_information____Done_
__0___Working_______________Hit_http___volatile_debian_net_sarge_volatile_main_Packages
______________3___Waiting_for_headers___Waiting_for_headers___Connecting_to_web_proxy__192_168__________________________________________________________________________________Hit_http___security_debian_org_sarge_updates_main_Packages
[18/[EMAIL PROTECTED] sarge]:~$ sudo cron-apt  -i -s | head -n 10
CRON-APT RUN [/etc/cron-apt/config]: Sun Jul  3 21:10:17 UTC 2005
CRON-APT ACTION: 0-update
CRON-APT LINE: update -o quiet=2
Reading Package Lists... Done
Building Dependency Tree
Reading extended state information
Initializing package states... Done
Writing extended state information... Done
Hit http://zg.debian.zugschlus.de zg/sarge/main Packages
Hit http://volatile.debian.net sarge/volatile/main Packages
[19/[EMAIL PROTECTED] sarge]:~$                      

> > --- 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")

Nice idea.

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

And that is POSIX sed? I though that of a GNU extension.

> > +                   < "$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.

That's a matter of personal style. I think that writing the
redirection source in front is much more natural, and providing the
input on the binary's stdin instead of the command line makes it
easier to put in other commands into the pipe. Since some tools behave
differently with stdin input, these behavior changes can make
debugging and extension harder.

> 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"

No, that one is as bad as the original, leaving in the status blurb
that is eaten by my more complicated regexp.

Greetings
Marc

-- 
-----------------------------------------------------------------------------
Marc Haber         | "I don't trust Computers. They | Mailadresse im Header
Mannheim, Germany  |  lose things."    Winona Ryder | Fon: *49 621 72739834
Nordisch by Nature |  How to make an American Quilt | Fax: *49 621 72739835


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

Reply via email to