mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 03:54:04 +08:00
Fix to stop reporting config.fish execution as coming from "standard
input" within backtraces
This commit is contained in:
parent
3ab954644f
commit
adf5b036d6
2
fish.cpp
2
fish.cpp
|
@ -227,7 +227,9 @@ static void source_config_in_directory(const wcstring &dir)
|
|||
const wcstring escaped_dir = escape_string(dir, ESCAPE_ALL);
|
||||
const wcstring cmd = L"builtin source " + escaped_dir + L"/config.fish 2>/dev/null";
|
||||
parser_t &parser = parser_t::principal_parser();
|
||||
parser.set_is_within_fish_initialization(true);
|
||||
parser.eval(cmd, io_chain_t(), TOP);
|
||||
parser.set_is_within_fish_initialization(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
31
parser.cpp
31
parser.cpp
|
@ -299,6 +299,7 @@ parser_t::parser_t(enum parser_type_t type, bool errors) :
|
|||
error_code(0),
|
||||
err_pos(0),
|
||||
cancellation_requested(false),
|
||||
is_within_fish_initialization(false),
|
||||
current_tokenizer(NULL),
|
||||
current_tokenizer_pos(0),
|
||||
job_start_pos(0),
|
||||
|
@ -322,6 +323,11 @@ parser_t &parser_t::principal_parser(void)
|
|||
return parser;
|
||||
}
|
||||
|
||||
void parser_t::set_is_within_fish_initialization(bool flag)
|
||||
{
|
||||
is_within_fish_initialization = flag;
|
||||
}
|
||||
|
||||
void parser_t::skip_all_blocks(void)
|
||||
{
|
||||
/* Tell all blocks to skip */
|
||||
|
@ -858,10 +864,13 @@ void parser_t::stack_trace(size_t block_idx, wcstring &buff) const
|
|||
b->src_lineno,
|
||||
user_presentable_path(file).c_str());
|
||||
}
|
||||
else if (is_within_fish_initialization)
|
||||
{
|
||||
append_format(buff, _(L"\tcalled during startup\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
append_format(buff,
|
||||
_(L"\tcalled on standard input\n"));
|
||||
append_format(buff, _(L"\tcalled on standard input\n"));
|
||||
}
|
||||
|
||||
if (b->type() == FUNCTION_CALL)
|
||||
|
@ -1064,15 +1073,17 @@ const wchar_t *parser_t::current_line()
|
|||
{
|
||||
int prev_width = my_wcswidth(lineinfo.c_str());
|
||||
if (file)
|
||||
append_format(lineinfo,
|
||||
_(L"%ls (line %d): "),
|
||||
file,
|
||||
lineno);
|
||||
{
|
||||
append_format(lineinfo, _(L"%ls (line %d): "), file, lineno);
|
||||
}
|
||||
else if (is_within_fish_initialization)
|
||||
{
|
||||
append_format(lineinfo, L"%ls: ", _(L"Startup"), lineno);
|
||||
}
|
||||
else
|
||||
append_format(lineinfo,
|
||||
L"%ls: ",
|
||||
_(L"Standard input"),
|
||||
lineno);
|
||||
{
|
||||
append_format(lineinfo, L"%ls: ", _(L"Standard input"), lineno);
|
||||
}
|
||||
offset = my_wcswidth(lineinfo.c_str()) - prev_width;
|
||||
}
|
||||
else
|
||||
|
|
6
parser.h
6
parser.h
|
@ -283,6 +283,9 @@ private:
|
|||
|
||||
/** Indication that we should skip all blocks */
|
||||
bool cancellation_requested;
|
||||
|
||||
/** Indicates that we are within the process of initializing fish */
|
||||
bool is_within_fish_initialization;
|
||||
|
||||
/** Stack of execution contexts. We own these pointers and must delete them */
|
||||
std::vector<parse_execution_context_t *> execution_contexts;
|
||||
|
@ -447,6 +450,9 @@ public:
|
|||
{
|
||||
return my_job_list;
|
||||
}
|
||||
|
||||
/* Hackish. In order to correctly report the origin of code with no associated file, we need to know whether it's run during initialization or not. */
|
||||
void set_is_within_fish_initialization(bool flag);
|
||||
|
||||
/** Pushes the block. pop_block will call delete on it. */
|
||||
void push_block(block_t *newv);
|
||||
|
|
Loading…
Reference in New Issue
Block a user