Junio C Hamano <gits...@pobox.com> writes:

> I wonder if we can do something like
> ...
> to tentatively give a message without permanently wasting the
> vertical space.

Learning from 13e4760a ("recv_sideband: Do not use ANSI escape
sequence on dumb terminals.", 2008-01-08), I think the above should
be more like this:

        git_spawn_editor()
        {
                static const char *finish;

                if (!finish) {
                        const char ANSI_FINISH[] = "\r\033[K";
                        const char DUMB_FINISH[] = "done.\n";
                        char *term = getenv("TERM");

                        if (term && strcmp(term, "dumb"))
                                finish = ANSI_FINISH;
                        else
                                finish = DUMB_FINISH;
                }

                /* notice the lack of terminating LF */
                fprintf(stderr, "Launched your editor, waiting...");
                fflush(stderr);

                if (!run_command(... spawn the editor ...))
                        fputs(finish, stderr);
                else
                        fprintf(stderr, "failed (%s)\n", strerror(errno));
                fflush(stderr);
        }

Reply via email to