From 85ba2ed790b247b79acde136a2c640417bc140e0 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Sun, 3 Jan 2021 17:41:38 +0100 Subject: [PATCH] type: Add missing newline Otherwise this would print # Defined interactivelyfunction foo for interactively defined functions. --- src/builtin_type.cpp | 2 +- tests/pexpects/generic.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/builtin_type.cpp b/src/builtin_type.cpp index cdd64c3df..3a1fa3ec8 100644 --- a/src/builtin_type.cpp +++ b/src/builtin_type.cpp @@ -155,7 +155,7 @@ maybe_t builtin_type(parser_t &parser, io_streams_t &streams, wchar_t **arg def = comment.append(def); } else { wcstring comment; - append_format(comment, L"# Defined interactively"); + append_format(comment, L"# Defined interactively\n"); def = comment.append(def); } if (!streams.out_is_redirected && isatty(STDOUT_FILENO)) { diff --git a/tests/pexpects/generic.py b/tests/pexpects/generic.py index efff0bcb5..5dd0ed618 100644 --- a/tests/pexpects/generic.py +++ b/tests/pexpects/generic.py @@ -56,3 +56,11 @@ expect_prompt("error: no-execute mode enabled and no script given. Exiting") sendline("source; or echo failed") expect_prompt("failed") + +# See that `type` tells us the function was defined interactively. +sendline("function foo; end; type foo") +expect_str("foo is a function with definition\r\n") +expect_str("# Defined interactively\r\n") +expect_str("function foo") +expect_str("end") +expect_prompt()