On Thu, Jun 18, 2015 at 12:33:58PM +0200, Theo Buehler wrote: > Here's a silly ed(1) session: > > $ ed -p ":> " > :> P > P > *q > $ > > Notice how the prompt string changed from the custom prompt ":> " to > the default prompt "*". > > This behavior seems to contradict both the man page and POSIX: > > >From ed(1): > -p string Specifies a command prompt. This may be toggled on and off > with the P command. > > >From POSIX: > The P command shall cause ed to prompt with an <asterisk> ('*') (or > string, if -p is specified) for all subsequent commands. The P command > alternatively shall turn this mode on and off; it shall be initially on > if the -p option is specified; otherwise, off. > > With the patch below, the above session becomes > > $ ed -p ":> " > :> P > P > :> q > $ > > which, I believe, is closer to both the documentation and POSIX. > > This also matches the behavior of GNU Ed 1.10. >
this behaviour does seem more logical i guess. no one has stepped up to change it though, so i've added a note to our doc until such a time. thanks for the report. jmc > Index: bin/ed/main.c > =================================================================== > RCS file: /cvs/src/bin/ed/main.c,v > retrieving revision 1.43 > diff -u -p -r1.43 main.c > --- bin/ed/main.c 16 Jan 2015 06:39:32 -0000 1.43 > +++ bin/ed/main.c 18 Jun 2015 10:33:21 -0000 > @@ -110,7 +110,7 @@ top: > while ((c = getopt(argc, argv, "p:sx")) != -1) > switch (c) { > case 'p': /* set prompt */ > - prompt = optarg; > + dps = prompt = optarg; > break; > case 's': /* run script */ > scripted = 1; >