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.
>
it does seem odd, yes.
still, i'd like to know how netbsd and freebsd behave: all 3 manuals use
the same (ambiguous) text. it could be that we want to document it as a
difference to posix rather than change the behaviour (i'm not the guy to
judge whether a change in behaviour is warranted).
note also:
- posix isn;t explicit (surprise, surprise)
- posix also documents "bsd" systems as (simultaneously!) not supporting
"P" and supporting "P" as a synonym for "p"
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;
>