mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
Revert "Show how fish was executed, using argv[0] for program_name"
This reverts commit 1cb8b2a87b
.
argv[0] has the full path in it for a user when he executes it
out of $PATH. This is really annoying in the title which uses $_.
This commit is contained in:
parent
dd582abcc5
commit
fe67cc4f6e
11 changed files with 24 additions and 24 deletions
|
@ -429,7 +429,7 @@ int builtin_status(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
|||
streams.out.append(var->as_string());
|
||||
streams.out.push_back(L'\n');
|
||||
} else {
|
||||
streams.out.append(str2wcstring(program_name).c_str());
|
||||
streams.out.append(program_name);
|
||||
streams.out.push_back(L'\n');
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -554,7 +554,7 @@ unique_ptr<expression> test_parser::parse_args(const wcstring_list_t &args, wcst
|
|||
assert(result->range.end <= args.size());
|
||||
if (result->range.end < args.size()) {
|
||||
if (err.empty()) {
|
||||
append_format(err, L"%s: unexpected argument at index %lu: '%ls'\n", program_name,
|
||||
append_format(err, L"%ls: unexpected argument at index %lu: '%ls'\n", program_name,
|
||||
(unsigned long)result->range.end, args.at(result->range.end).c_str());
|
||||
}
|
||||
result.reset(NULL);
|
||||
|
|
|
@ -62,7 +62,7 @@ const wchar_t *ellipsis_str = nullptr;
|
|||
wchar_t omitted_newline_char;
|
||||
wchar_t obfuscation_read_char;
|
||||
bool g_profiling_active = false;
|
||||
const char *program_name;
|
||||
const wchar_t *program_name;
|
||||
int debug_level = 1; // default maximum debug output level (errors and warnings)
|
||||
int debug_stack_frames = 0; // default number of stack frames to show on debug() calls
|
||||
|
||||
|
@ -603,16 +603,16 @@ ssize_t read_loop(int fd, void *buff, size_t count) {
|
|||
/// like `debug()`. It is only intended to supress diagnostic noise from testing things like the
|
||||
/// fish parser where we expect a lot of diagnostic messages due to testing error conditions.
|
||||
bool should_suppress_stderr_for_tests() {
|
||||
return program_name && !strcmp(program_name, TESTS_PROGRAM_NAME);
|
||||
return program_name && !wcscmp(program_name, TESTS_PROGRAM_NAME);
|
||||
}
|
||||
|
||||
static void debug_shared(const wchar_t level, const wcstring &msg) {
|
||||
pid_t current_pid = getpid();
|
||||
|
||||
if (current_pid == initial_pid) {
|
||||
fwprintf(stderr, L"<%lc> %s: %ls\n", (unsigned long)level, program_name, msg.c_str());
|
||||
fwprintf(stderr, L"<%lc> %ls: %ls\n", (unsigned long)level, program_name, msg.c_str());
|
||||
} else {
|
||||
fwprintf(stderr, L"<%lc> %s: %d: %ls\n", (unsigned long)level, program_name, current_pid,
|
||||
fwprintf(stderr, L"<%lc> %ls: %d: %ls\n", (unsigned long)level, program_name, current_pid,
|
||||
msg.c_str());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -221,7 +221,7 @@ extern int debug_stack_frames;
|
|||
extern bool g_profiling_active;
|
||||
|
||||
/// Name of the current program. Should be set at startup. Used by the debug function.
|
||||
extern const char *program_name;
|
||||
extern const wchar_t *program_name;
|
||||
|
||||
/// Set to false if it's been determined we can't trust the last modified timestamp on the tty.
|
||||
extern const bool has_working_tty_timestamps;
|
||||
|
@ -532,7 +532,7 @@ string_fuzzy_match_t string_fuzzy_match_string(const wcstring &string,
|
|||
fuzzy_match_type_t limit_type = fuzzy_match_none);
|
||||
|
||||
// Check if we are running in the test mode, where we should suppress error output
|
||||
#define TESTS_PROGRAM_NAME "(ignore)"
|
||||
#define TESTS_PROGRAM_NAME L"(ignore)"
|
||||
bool should_suppress_stderr_for_tests();
|
||||
|
||||
void assert_is_main_thread(const char *who);
|
||||
|
|
|
@ -1047,7 +1047,7 @@ class universal_notifier_shmem_poller_t : public universal_notifier_t {
|
|||
|
||||
// Use a path based on our uid to avoid collisions.
|
||||
char path[NAME_MAX];
|
||||
snprintf(path, sizeof path, "/%s_shmem_%d", L"fish",
|
||||
snprintf(path, sizeof path, "/%ls_shmem_%d", program_name ? program_name : L"fish",
|
||||
getuid());
|
||||
|
||||
bool errored = false;
|
||||
|
@ -1181,7 +1181,8 @@ class universal_notifier_notifyd_t : public universal_notifier_t {
|
|||
void setup_notifyd() {
|
||||
// Per notify(3), the user.uid.%d style is only accessible to processes with that uid.
|
||||
char local_name[256];
|
||||
snprintf(local_name, sizeof local_name, "user.uid.%d.fish.uvars", getuid());
|
||||
snprintf(local_name, sizeof local_name, "user.uid.%d.%ls.uvars", getuid(),
|
||||
program_name ? program_name : L"fish");
|
||||
name.assign(local_name);
|
||||
|
||||
uint32_t status =
|
||||
|
|
15
src/fish.cpp
15
src/fish.cpp
|
@ -100,7 +100,7 @@ static struct config_paths_t determine_config_directory_paths(const char *argv0)
|
|||
#ifdef CMAKE_BINARY_DIR
|
||||
// Detect if we're running right out of the CMAKE build directory
|
||||
if (string_prefixes_string(CMAKE_BINARY_DIR, exec_path.c_str())) {
|
||||
debug(2, "Running out of5 build directory, using paths relative to CMAKE_SOURCE_DIR:\n %s", CMAKE_SOURCE_DIR);
|
||||
debug(2, "Running out of build directory, using paths relative to CMAKE_SOURCE_DIR:\n %s", CMAKE_SOURCE_DIR);
|
||||
|
||||
done = true;
|
||||
paths.data = wcstring{L"" CMAKE_SOURCE_DIR} + L"/share";
|
||||
|
@ -334,13 +334,7 @@ int main(int argc, char **argv) {
|
|||
int res = 1;
|
||||
int my_optind = 0;
|
||||
|
||||
const char *dummy_argv[2] = {"fish", NULL};
|
||||
if (!argv[0]) {
|
||||
argv = (char **)dummy_argv; //!OCLINT(parameter reassignment)
|
||||
argc = 1; //!OCLINT(parameter reassignment)
|
||||
}
|
||||
|
||||
program_name = argv[0];
|
||||
program_name = L"fish";
|
||||
set_main_thread();
|
||||
setup_fork_guards();
|
||||
signal_unblock_all();
|
||||
|
@ -350,6 +344,11 @@ int main(int argc, char **argv) {
|
|||
// struct stat tmp;
|
||||
// stat("----------FISH_HIT_MAIN----------", &tmp);
|
||||
|
||||
const char *dummy_argv[2] = {"fish", NULL};
|
||||
if (!argv[0]) {
|
||||
argv = (char **)dummy_argv; //!OCLINT(parameter reassignment)
|
||||
argc = 1; //!OCLINT(parameter reassignment)
|
||||
}
|
||||
fish_cmd_opts_t opts;
|
||||
my_optind = fish_parse_opt(argc, argv, &opts);
|
||||
|
||||
|
|
|
@ -381,7 +381,7 @@ static std::string html_colorize(const wcstring &text,
|
|||
static std::string no_colorize(const wcstring &text) { return wcs2string(text); }
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
program_name = argv[0];
|
||||
program_name = L"fish_indent";
|
||||
set_main_thread();
|
||||
setup_fork_guards();
|
||||
// Using the user's default locale could be a problem if it doesn't use UTF-8 encoding. That's
|
||||
|
|
|
@ -383,7 +383,7 @@ static bool parse_flags(int argc, char **argv, bool *continuous_mode) {
|
|||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
program_name = argv[0];
|
||||
program_name = L"fish_key_reader";
|
||||
bool continuous_mode = false;
|
||||
|
||||
if (!parse_flags(argc, argv, &continuous_mode)) return 1;
|
||||
|
|
|
@ -775,7 +775,7 @@ void parser_t::get_backtrace(const wcstring &src, const parse_error_list_t &erro
|
|||
prefix = format_string(_(L"%ls: "), user_presentable_path(filename).c_str());
|
||||
}
|
||||
} else {
|
||||
prefix = format_string(L"%s: ", program_name);
|
||||
prefix = L"fish: ";
|
||||
}
|
||||
|
||||
const wcstring description =
|
||||
|
|
|
@ -655,7 +655,7 @@ static int process_clean_after_marking(bool allow_interactive) {
|
|||
// we don't need to.
|
||||
const wcstring job_number_desc =
|
||||
(job_count == 1) ? wcstring() : format_string(_(L"Job %d, "), j->job_id);
|
||||
fwprintf(stdout, _(L"%s: %ls\'%ls\' terminated by signal %ls (%ls)"),
|
||||
fwprintf(stdout, _(L"%ls: %ls\'%ls\' terminated by signal %ls (%ls)"),
|
||||
program_name, job_number_desc.c_str(),
|
||||
truncate_command(j->command()).c_str(), sig2wcs(WTERMSIG(p->status)),
|
||||
signal_get_desc(WTERMSIG(p->status)));
|
||||
|
@ -663,7 +663,7 @@ static int process_clean_after_marking(bool allow_interactive) {
|
|||
const wcstring job_number_desc =
|
||||
(job_count == 1) ? wcstring() : format_string(L"from job %d, ", j->job_id);
|
||||
const wchar_t *fmt =
|
||||
_(L"%s: Process %d, \'%ls\' %ls\'%ls\' terminated by signal %ls (%ls)");
|
||||
_(L"%ls: Process %d, \'%ls\' %ls\'%ls\' terminated by signal %ls (%ls)");
|
||||
fwprintf(stdout, fmt, program_name, p->pid, p->argv0(), job_number_desc.c_str(),
|
||||
truncate_command(j->command()).c_str(), sig2wcs(WTERMSIG(p->status)),
|
||||
signal_get_desc(WTERMSIG(p->status)));
|
||||
|
|
|
@ -2037,7 +2037,7 @@ void reader_run_command(parser_t &parser, const wcstring &cmd) {
|
|||
term_steal();
|
||||
|
||||
// For compatibility with fish 2.0's $_, now replaced with `status current-command`
|
||||
env_set_one(L"_", ENV_GLOBAL, str2wcstring(program_name).c_str());
|
||||
env_set_one(L"_", ENV_GLOBAL, program_name);
|
||||
|
||||
#ifdef HAVE__PROC_SELF_STAT
|
||||
proc_update_jiffies();
|
||||
|
|
Loading…
Reference in a new issue