type: Add missing newline

Otherwise this would print

    # Defined interactivelyfunction foo

for interactively defined functions.
This commit is contained in:
Fabian Homborg 2021-01-03 17:41:38 +01:00
parent 627fff7971
commit 85ba2ed790
2 changed files with 9 additions and 1 deletions

View file

@ -155,7 +155,7 @@ maybe_t<int> 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)) {

View file

@ -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()