From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19127 invoked from network); 24 Jul 2005 18:02:01 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 24 Jul 2005 18:02:01 -0000 Received: (qmail 82011 invoked from network); 24 Jul 2005 18:01:56 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 24 Jul 2005 18:01:56 -0000 Received: (qmail 3915 invoked by alias); 24 Jul 2005 18:01:53 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 21518 Received: (qmail 3906 invoked from network); 24 Jul 2005 18:01:53 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 24 Jul 2005 18:01:53 -0000 Received: (qmail 81668 invoked from network); 24 Jul 2005 18:01:53 -0000 Received: from mail.gmx.de (HELO mail.gmx.net) (213.165.64.20) by a.mx.sunsite.dk with SMTP; 24 Jul 2005 18:01:47 -0000 Received: (qmail invoked by alias); 24 Jul 2005 18:01:44 -0000 Received: from Bc8d0.b.pppool.de (EHLO pcdahl4201) [213.7.200.208] by mail.gmx.net (mp022) with SMTP; 24 Jul 2005 20:01:44 +0200 X-Authenticated: #21620914 Message-ID: <00c701c5907a$df03b860$b63dfea9@pcdahl4201> From: "Thorsten Dahlheimer" To: "Wayne Davison" Cc: References: <003c01c58ff5$870469a0$13e6fea9@pcdahl4201> <20050724055220.GA19554@blorf.net> Subject: Re: PATCH: Expansion of \c escape sequences Date: Sun, 24 Jul 2005 20:09:40 +0200 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_00C4_01C5908B.9FAA01E0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 X-Y-GMX-Trusted: 0 X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00, MIME_QP_LONG_LINE autolearn=ham version=3.0.4 This is a multi-part message in MIME format. ------=_NextPart_000_00C4_01C5908B.9FAA01E0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Wayne Davison wrote: > I'm curious which version of coreutils behaves that way? I've got 5.2.1 > on my system, and it behaves as zsh does. Indeed, echo seems to have been changed after the 5.2.1 release (I tested with 5.3.0). Printf behaves as I described even in 5.2.1, though. > If we want to change the > behavior, the attached patch should handle it. Not quite, since it doesn't handle these cases: %/usr/bin/echo -e 'a\c' b a %/usr/bin/printf '%s\c%s' a b c a %/usr/bin/printf '%b %b\n' a b 'c\c' d e a b c I've attached an extended patch that should do this. Regards, Thorsten Dahlheimer ------=_NextPart_000_00C4_01C5908B.9FAA01E0 Content-Type: application/octet-stream; name="backslash-c_2.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="backslash-c_2.patch" Index: Src/builtin.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v=0A= retrieving revision 1.140=0A= diff -u -p -r1.140 builtin.c=0A= --- Src/builtin.c 17 Jun 2005 08:37:46 -0000 1.140=0A= +++ Src/builtin.c 24 Jul 2005 17:39:28 -0000=0A= @@ -3284,7 +3284,7 @@ int=0A= bin_print(char *name, char **args, Options ops, int func)=0A= {=0A= int flen, width, prec, type, argc, n, narg;=0A= - int nnl =3D 0, ret =3D 0, maxarg =3D 0;=0A= + int nnl =3D 0, ret =3D 0, maxarg =3D 0, fmtbsc =3D 0;=0A= int flags[5], *len;=0A= char *start, *endptr, *c, *d, *flag, *buf, spec[13], *fmt =3D NULL;=0A= char **first, *curarg, *flagch =3D "0+- #", save =3D '\0', nullstr = =3D '\0';=0A= @@ -3313,7 +3313,7 @@ bin_print(char *name, char **args, Optio=0A= else if (OPT_HASARG(ops,'f'))=0A= fmt =3D OPT_ARG(ops,'f');=0A= if (fmt)=0A= - fmt =3D getkeystring(fmt, &flen, OPT_ISSET(ops,'b') ? 2 : 0, &nnl);=0A= + fmt =3D getkeystring(fmt, &flen, OPT_ISSET(ops,'b') ? 2 : 0, &fmtbsc);=0A= =0A= first =3D args;=0A= =0A= @@ -3349,10 +3349,15 @@ bin_print(char *name, char **args, Optio=0A= (!OPT_ISSET(ops,'e') && =0A= (OPT_ISSET(ops,'R') || OPT_ISSET(ops,'r') || OPT_ISSET(ops,'E'))))=0A= unmetafy(args[n], &len[n]);=0A= - else=0A= + else {=0A= args[n] =3D getkeystring(args[n], &len[n], OPT_ISSET(ops,'b') ? 2 :=0A= (func !=3D BIN_ECHO && !OPT_ISSET(ops,'e')),=0A= &nnl);=0A= + if (nnl) {=0A= + args[n + 1] =3D NULL;=0A= + argc =3D n + 1;=0A= + }=0A= + }=0A= /* -P option -- interpret as a prompt sequence */=0A= if(OPT_ISSET(ops,'P')) {=0A= /*=0A= @@ -3754,6 +3759,8 @@ bin_print(char *name, char **args, Optio=0A= if (width < 0 && l < -width)=0A= printf("%*c", -width - l, ' ');=0A= count +=3D l;=0A= + if (nnl)=0A= + goto printf_finished;=0A= }=0A= break;=0A= case 'q':=0A= @@ -3854,8 +3861,9 @@ bin_print(char *name, char **args, Optio=0A= =0A= if (maxarg) args =3D first + maxarg;=0A= /* if there are remaining args, reuse format string */=0A= - } while (*args && args !=3D first && !OPT_ISSET(ops,'r'));=0A= + } while (*args && args !=3D first && !fmtbsc && = !OPT_ISSET(ops,'r'));=0A= =0A= +printf_finished:=0A= if (OPT_ISSET(ops,'z') || OPT_ISSET(ops,'s')) {=0A= #ifdef HAVE_OPEN_MEMSTREAM=0A= putc(0, fout);=0A= Index: Src/utils.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvsroot/zsh/zsh/Src/utils.c,v=0A= retrieving revision 1.80=0A= diff -u -p -r1.80 utils.c=0A= --- Src/utils.c 24 Jul 2005 05:19:58 -0000 1.80=0A= +++ Src/utils.c 24 Jul 2005 17:40:03 -0000=0A= @@ -3611,7 +3611,9 @@ getkeystring(char *s, int *len, int from=0A= case 'c':=0A= if (fromwhere < 2) {=0A= *misc =3D 1;=0A= - break;=0A= + *t =3D '\0';=0A= + *len =3D t - buf;=0A= + return buf;=0A= }=0A= goto def;=0A= case 'u':=0A= ------=_NextPart_000_00C4_01C5908B.9FAA01E0--