diff --git a/builtin.cpp b/builtin.cpp index d230080a4e3d..d01322e21aef 100644 --- a/builtin.cpp +++ b/builtin.cpp @@ -3014,7 +3014,7 @@ static int builtin_source(parser_t &parser, wchar_t ** argv) if ((fd = wopen_cloexec(argv[1], O_RDONLY)) == -1) { append_format(stderr_buffer, _(L"%ls: Error encountered while sourcing file '%ls':\n"), argv[0], argv[1]); - builtin_wperror(L"."); + builtin_wperror(L"source"); return STATUS_BUILTIN_ERROR; } @@ -3022,7 +3022,7 @@ static int builtin_source(parser_t &parser, wchar_t ** argv) { close(fd); append_format(stderr_buffer, _(L"%ls: Error encountered while sourcing file '%ls':\n"), argv[0], argv[1]); - builtin_wperror(L"."); + builtin_wperror(L"source"); return STATUS_BUILTIN_ERROR; } @@ -3953,7 +3953,6 @@ static int builtin_history(parser_t &parser, wchar_t **argv) */ static const builtin_data_t builtin_datas[]= { - { L".", &builtin_source, N_(L"Evaluate contents of file") }, { L"[", &builtin_test, N_(L"Test a condition") }, { L"and", &builtin_generic, N_(L"Execute command if previous command suceeded") }, { L"begin", &builtin_begin, N_(L"Create a block of code") }, @@ -3993,6 +3992,7 @@ static const builtin_data_t builtin_datas[]= { L"return", &builtin_return, N_(L"Stop the currently evaluated function") }, { L"set", &builtin_set, N_(L"Handle environment variables") }, { L"set_color", &builtin_set_color, N_(L"Set the terminal color") }, + { L"source", &builtin_source, N_(L"Evaluate contents of file") }, { L"status", &builtin_status, N_(L"Return status information about fish") }, { L"switch", &builtin_switch, N_(L"Conditionally execute a block of commands") }, { L"test", &builtin_test, N_(L"Test a condition") }, diff --git a/fish.cpp b/fish.cpp index fda24360cec9..2251d8ecb311 100644 --- a/fish.cpp +++ b/fish.cpp @@ -217,8 +217,8 @@ static int read_init(const struct config_paths_t &paths) { parser_t &parser = parser_t::principal_parser(); const io_chain_t empty_ios; - parser.eval(L"builtin . " + paths.data + L"/config.fish 2>/dev/null", empty_ios, TOP); - parser.eval(L"builtin . " + paths.sysconf + L"/config.fish 2>/dev/null", empty_ios, TOP); + parser.eval(L"builtin source " + paths.data + L"/config.fish 2>/dev/null", empty_ios, TOP); + parser.eval(L"builtin source " + paths.sysconf + L"/config.fish 2>/dev/null", empty_ios, TOP); /* @@ -233,7 +233,7 @@ static int read_init(const struct config_paths_t &paths) if (path_get_config(config_dir)) { wcstring config_dir_escaped = escape_string(config_dir, 1); - wcstring eval_buff = format_string(L"builtin . %ls/config.fish 2>/dev/null", config_dir_escaped.c_str()); + wcstring eval_buff = format_string(L"builtin source %ls/config.fish 2>/dev/null", config_dir_escaped.c_str()); parser.eval(eval_buff, empty_ios, TOP); } diff --git a/share/config.fish b/share/config.fish index 056fd34f7971..e0b07bf9e90d 100644 --- a/share/config.fish +++ b/share/config.fish @@ -109,3 +109,16 @@ function __fish_on_interactive --on-event fish_prompt functions -e __fish_on_interactive end +# "." command for compatibility with old fish versions. +function . --description 'Evaluate contents of file (deprecated, see "source")' + if begin + test (count $argv) -eq 0 + # Uses tty directly, as isatty depends on "." + and tty 0>&0 >/dev/null + end + echo "source: '.' command is deprecated, and doesn't work with STDIN anymore. Did you mean 'source' or './'?" >&2 + return 1 + else + source $argv + end +end