mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
change order of env_set()
args
It's bugged me forever that the scope is the second arg to `env_get()` but not `env_set()`. And since I'll be introducing some helper functions that wrap `env_set()` now is a good time to change the order of its arguments.
This commit is contained in:
parent
751d5503a1
commit
6e7956a413
15 changed files with 65 additions and 65 deletions
|
@ -458,13 +458,13 @@ static int validate_arg(argparse_cmd_opts_t &opts, option_spec_t *opt_spec, bool
|
|||
wcstring_list_t cmd_output;
|
||||
|
||||
env_push(true);
|
||||
env_set(L"_argparse_cmd", opts.name.c_str(), ENV_LOCAL);
|
||||
env_set(L"_argparse_cmd", ENV_LOCAL, opts.name.c_str());
|
||||
if (is_long_flag) {
|
||||
env_set(var_name_prefix + L"name", opt_spec->long_flag.c_str(), ENV_LOCAL);
|
||||
env_set(var_name_prefix + L"name", ENV_LOCAL, opt_spec->long_flag.c_str());
|
||||
} else {
|
||||
env_set(var_name_prefix + L"name", wcstring(1, opt_spec->short_flag).c_str(), ENV_LOCAL);
|
||||
env_set(var_name_prefix + L"name", ENV_LOCAL, wcstring(1, opt_spec->short_flag).c_str());
|
||||
}
|
||||
env_set(var_name_prefix + L"value", woptarg, ENV_LOCAL);
|
||||
env_set(var_name_prefix + L"value", ENV_LOCAL, woptarg);
|
||||
|
||||
int retval = exec_subshell(opt_spec->validation_command, cmd_output, false);
|
||||
for (auto it : cmd_output) {
|
||||
|
@ -645,7 +645,7 @@ static void set_argparse_result_vars(argparse_cmd_opts_t &opts) {
|
|||
|
||||
auto val = list_to_array_val(opt_spec->vals);
|
||||
if (opt_spec->short_flag_valid) {
|
||||
env_set(var_name_prefix + opt_spec->short_flag, val->c_str(), ENV_LOCAL);
|
||||
env_set(var_name_prefix + opt_spec->short_flag, ENV_LOCAL, val->c_str());
|
||||
}
|
||||
if (!opt_spec->long_flag.empty()) {
|
||||
// We do a simple replacement of all non alphanum chars rather than calling
|
||||
|
@ -654,12 +654,12 @@ static void set_argparse_result_vars(argparse_cmd_opts_t &opts) {
|
|||
for (size_t pos = 0; pos < long_flag.size(); pos++) {
|
||||
if (!iswalnum(long_flag[pos])) long_flag[pos] = L'_';
|
||||
}
|
||||
env_set(var_name_prefix + long_flag, val->c_str(), ENV_LOCAL);
|
||||
env_set(var_name_prefix + long_flag, ENV_LOCAL, val->c_str());
|
||||
}
|
||||
}
|
||||
|
||||
auto val = list_to_array_val(opts.argv);
|
||||
env_set(L"argv", val->c_str(), ENV_LOCAL);
|
||||
env_set(L"argv", ENV_LOCAL, val->c_str());
|
||||
}
|
||||
|
||||
/// The argparse builtin. This is explicitly not compatible with the BSD or GNU version of this
|
||||
|
|
|
@ -102,7 +102,7 @@ int builtin_fg(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
|||
}
|
||||
|
||||
const wcstring ft = tok_first(j->command());
|
||||
if (!ft.empty()) env_set(L"_", ft.c_str(), ENV_EXPORT);
|
||||
if (!ft.empty()) env_set(L"_", ENV_EXPORT, ft.c_str());
|
||||
reader_write_title(j->command());
|
||||
|
||||
job_promote(j);
|
||||
|
|
|
@ -422,7 +422,7 @@ int builtin_read(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
|||
if (exit_res != STATUS_CMD_OK) {
|
||||
// Define the var(s) without any data. We do this because when this happens we want the user
|
||||
// to be able to use the var but have it expand to nothing.
|
||||
for (int i = 0; i < argc; i++) env_set(argv[i], NULL, opts.place);
|
||||
for (int i = 0; i < argc; i++) env_set(argv[i], opts.place, NULL);
|
||||
return exit_res;
|
||||
}
|
||||
|
||||
|
@ -444,9 +444,9 @@ int builtin_read(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
|||
*out = *it;
|
||||
out += 2;
|
||||
}
|
||||
env_set(argv[0], chars.c_str(), opts.place);
|
||||
env_set(argv[0], opts.place, chars.c_str());
|
||||
} else {
|
||||
env_set(argv[0], NULL, opts.place);
|
||||
env_set(argv[0], opts.place, NULL);
|
||||
}
|
||||
} else { // not array mode
|
||||
int i = 0;
|
||||
|
@ -454,12 +454,12 @@ int builtin_read(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
|||
for (; i + 1 < argc; ++i) {
|
||||
if (j < bufflen) {
|
||||
wchar_t buffer[2] = {buff[j++], 0};
|
||||
env_set(argv[i], buffer, opts.place);
|
||||
env_set(argv[i], opts.place, buffer);
|
||||
} else {
|
||||
env_set(argv[i], L"", opts.place);
|
||||
env_set(argv[i], opts.place, L"");
|
||||
}
|
||||
}
|
||||
if (i < argc) env_set(argv[i], &buff[j], opts.place);
|
||||
if (i < argc) env_set(argv[i], opts.place, &buff[j]);
|
||||
}
|
||||
} else if (opts.array) {
|
||||
if (!opts.have_delimiter) {
|
||||
|
@ -473,21 +473,21 @@ int builtin_read(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
|||
if (!tokens.empty()) tokens.push_back(ARRAY_SEP);
|
||||
tokens.append(buff, loc.first, loc.second);
|
||||
}
|
||||
env_set(argv[0], tokens.empty() ? NULL : tokens.c_str(), opts.place);
|
||||
env_set(argv[0], opts.place, tokens.empty() ? NULL : tokens.c_str());
|
||||
} else {
|
||||
wcstring_list_t splits;
|
||||
split_about(buff.begin(), buff.end(), opts.delimiter.begin(), opts.delimiter.end(),
|
||||
&splits, LONG_MAX);
|
||||
auto val = list_to_array_val(splits);
|
||||
env_set(argv[0], val->c_str(), opts.place);
|
||||
env_set(argv[0], opts.place, val->c_str());
|
||||
}
|
||||
} else { // not array
|
||||
if (!opts.have_delimiter) {
|
||||
wcstring_range loc = wcstring_range(0, 0);
|
||||
for (int i = 0; i < argc; i++) {
|
||||
loc = wcstring_tok(buff, (i + 1 < argc) ? opts.delimiter : wcstring(), loc);
|
||||
env_set(argv[i], loc.first == wcstring::npos ? L"" : &buff.c_str()[loc.first],
|
||||
opts.place);
|
||||
env_set(argv[i], opts.place,
|
||||
loc.first == wcstring::npos ? L"" : &buff.c_str()[loc.first]);
|
||||
}
|
||||
} else {
|
||||
wcstring_list_t splits;
|
||||
|
@ -496,7 +496,7 @@ int builtin_read(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
|||
split_about(buff.begin(), buff.end(), opts.delimiter.begin(), opts.delimiter.end(),
|
||||
&splits, argc - 1);
|
||||
for (size_t i = 0; i < (size_t)argc && i < splits.size(); i++) {
|
||||
env_set(argv[i], splits[i].c_str(), opts.place);
|
||||
env_set(argv[i], opts.place, splits[i].c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -284,8 +284,8 @@ static int my_env_path_setup(const wchar_t *cmd, const wchar_t *key, //!OCLINT(
|
|||
|
||||
/// Call env_set. If this is a path variable, e.g. PATH, validate the elements. On error, print a
|
||||
/// description of the problem to stderr.
|
||||
static int my_env_set(const wchar_t *cmd, const wchar_t *key, const wcstring_list_t &list,
|
||||
int scope, io_streams_t &streams) {
|
||||
static int my_env_set(const wchar_t *cmd, const wchar_t *key, int scope,
|
||||
const wcstring_list_t &list, io_streams_t &streams) {
|
||||
int retval;
|
||||
|
||||
if (is_path_variable(key)) {
|
||||
|
@ -294,7 +294,7 @@ static int my_env_set(const wchar_t *cmd, const wchar_t *key, const wcstring_lis
|
|||
}
|
||||
|
||||
auto val = list_to_array_val(list);
|
||||
retval = env_set(key, val->c_str(), scope | ENV_USER);
|
||||
retval = env_set(key, scope | ENV_USER, val->c_str());
|
||||
switch (retval) {
|
||||
case ENV_OK: {
|
||||
retval = STATUS_CMD_OK;
|
||||
|
@ -633,7 +633,7 @@ static int builtin_set_erase(const wchar_t *cmd, set_cmd_opts_t &opts, int argc,
|
|||
wcstring_list_t result;
|
||||
dest_var.to_list(result);
|
||||
erase_values(result, indexes);
|
||||
retval = my_env_set(cmd, dest, result, scope, streams);
|
||||
retval = my_env_set(cmd, dest, scope, result, streams);
|
||||
}
|
||||
|
||||
if (retval != STATUS_CMD_OK) return retval;
|
||||
|
@ -742,7 +742,7 @@ static int builtin_set_set(const wchar_t *cmd, set_cmd_opts_t &opts, int argc, w
|
|||
}
|
||||
if (retval != STATUS_CMD_OK) return retval;
|
||||
|
||||
retval = my_env_set(cmd, varname, new_values, scope, streams);
|
||||
retval = my_env_set(cmd, varname, scope, new_values, streams);
|
||||
if (retval != STATUS_CMD_OK) return retval;
|
||||
return check_global_scope_exists(cmd, opts, varname, streams);
|
||||
}
|
||||
|
|
|
@ -1583,11 +1583,11 @@ static void export_new_termsize(struct winsize *new_termsize) {
|
|||
wchar_t buf[64];
|
||||
env_var_t cols = env_get(L"COLUMNS", ENV_EXPORT);
|
||||
swprintf(buf, 64, L"%d", (int)new_termsize->ws_col);
|
||||
env_set(L"COLUMNS", buf, ENV_GLOBAL | (cols.missing_or_empty() ? 0 : ENV_EXPORT));
|
||||
env_set(L"COLUMNS", ENV_GLOBAL | (cols.missing_or_empty() ? 0 : ENV_EXPORT), buf);
|
||||
|
||||
env_var_t lines = env_get(L"LINES", ENV_EXPORT);
|
||||
swprintf(buf, 64, L"%d", (int)new_termsize->ws_row);
|
||||
env_set(L"LINES", buf, ENV_GLOBAL | (lines.missing_or_empty() ? 0 : ENV_EXPORT));
|
||||
env_set(L"LINES", ENV_GLOBAL | (lines.missing_or_empty() ? 0 : ENV_EXPORT), buf);
|
||||
|
||||
#ifdef HAVE_WINSIZE
|
||||
ioctl(STDOUT_FILENO, TIOCSWINSZ, new_termsize);
|
||||
|
|
44
src/env.cpp
44
src/env.cpp
|
@ -369,7 +369,7 @@ static void fix_colon_delimited_var(const wcstring &var_name) {
|
|||
}
|
||||
}
|
||||
|
||||
int scope = env_set(var_name, new_val.c_str(), ENV_USER);
|
||||
int scope = env_set(var_name, ENV_USER, new_val.c_str());
|
||||
if (scope != ENV_OK) {
|
||||
debug(0, L"fix_colon_delimited_var failed unexpectedly with retval %d", scope);
|
||||
}
|
||||
|
@ -667,7 +667,7 @@ static void setup_path() {
|
|||
const env_var_t path = env_get(L"PATH");
|
||||
if (path.missing_or_empty()) {
|
||||
const wchar_t *value = L"/usr/bin" ARRAY_SEP_STR L"/bin";
|
||||
env_set(L"PATH", value, ENV_GLOBAL | ENV_EXPORT);
|
||||
env_set(L"PATH", ENV_GLOBAL | ENV_EXPORT, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -676,10 +676,10 @@ static void setup_path() {
|
|||
/// adjusted.
|
||||
static void env_set_termsize() {
|
||||
env_var_t cols = env_get(L"COLUMNS");
|
||||
if (cols.missing_or_empty()) env_set(L"COLUMNS", DFLT_TERM_COL_STR, ENV_GLOBAL);
|
||||
if (cols.missing_or_empty()) env_set(L"COLUMNS", ENV_GLOBAL, DFLT_TERM_COL_STR);
|
||||
|
||||
env_var_t rows = env_get(L"LINES");
|
||||
if (rows.missing_or_empty()) env_set(L"LINES", DFLT_TERM_ROW_STR, ENV_GLOBAL);
|
||||
if (rows.missing_or_empty()) env_set(L"LINES", ENV_GLOBAL, DFLT_TERM_ROW_STR);
|
||||
}
|
||||
|
||||
bool env_set_pwd() {
|
||||
|
@ -689,7 +689,7 @@ bool env_set_pwd() {
|
|||
_(L"Could not determine current working directory. Is your locale set correctly?"));
|
||||
return false;
|
||||
}
|
||||
env_set(L"PWD", res.c_str(), ENV_EXPORT | ENV_GLOBAL);
|
||||
env_set(L"PWD", ENV_EXPORT | ENV_GLOBAL, res.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -728,7 +728,7 @@ static void setup_user(bool force) {
|
|||
int retval = getpwuid_r(getuid(), &userinfo, buf, sizeof(buf), &result);
|
||||
if (!retval && result) {
|
||||
const wcstring uname = str2wcstring(userinfo.pw_name);
|
||||
env_set(L"USER", uname.c_str(), ENV_GLOBAL | ENV_EXPORT);
|
||||
env_set(L"USER", ENV_GLOBAL | ENV_EXPORT, uname.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -820,7 +820,7 @@ void env_init(const struct config_paths_t *paths /* or NULL */) {
|
|||
if (eql == wcstring::npos) {
|
||||
// No equals found.
|
||||
if (is_read_only(key_and_val) || is_electric(key_and_val)) continue;
|
||||
env_set(key_and_val, L"", ENV_EXPORT | ENV_GLOBAL);
|
||||
env_set(key_and_val, ENV_EXPORT | ENV_GLOBAL, L"");
|
||||
} else {
|
||||
key.assign(key_and_val, 0, eql);
|
||||
if (is_read_only(key) || is_electric(key)) continue;
|
||||
|
@ -829,16 +829,16 @@ void env_init(const struct config_paths_t *paths /* or NULL */) {
|
|||
std::replace(val.begin(), val.end(), L':', ARRAY_SEP);
|
||||
}
|
||||
|
||||
env_set(key, val.c_str(), ENV_EXPORT | ENV_GLOBAL);
|
||||
env_set(key, ENV_EXPORT | ENV_GLOBAL, val.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
// Set the given paths in the environment, if we have any.
|
||||
if (paths != NULL) {
|
||||
env_set(FISH_DATADIR_VAR, paths->data.c_str(), ENV_GLOBAL);
|
||||
env_set(FISH_SYSCONFDIR_VAR, paths->sysconf.c_str(), ENV_GLOBAL);
|
||||
env_set(FISH_HELPDIR_VAR, paths->doc.c_str(), ENV_GLOBAL);
|
||||
env_set(FISH_BIN_DIR, paths->bin.c_str(), ENV_GLOBAL);
|
||||
env_set(FISH_DATADIR_VAR, ENV_GLOBAL, paths->data.c_str());
|
||||
env_set(FISH_SYSCONFDIR_VAR, ENV_GLOBAL, paths->sysconf.c_str());
|
||||
env_set(FISH_HELPDIR_VAR, ENV_GLOBAL, paths->doc.c_str());
|
||||
env_set(FISH_BIN_DIR, ENV_GLOBAL, paths->bin.c_str());
|
||||
}
|
||||
|
||||
init_locale();
|
||||
|
@ -859,7 +859,7 @@ void env_init(const struct config_paths_t *paths /* or NULL */) {
|
|||
|
||||
// Set up the version variable.
|
||||
wcstring version = str2wcstring(get_fish_version());
|
||||
env_set(L"FISH_VERSION", version.c_str(), ENV_GLOBAL);
|
||||
env_set(L"FISH_VERSION", ENV_GLOBAL, version.c_str());
|
||||
|
||||
// Set up SHLVL variable.
|
||||
const env_var_t shlvl_var = env_get(L"SHLVL");
|
||||
|
@ -872,7 +872,7 @@ void env_init(const struct config_paths_t *paths /* or NULL */) {
|
|||
nshlvl_str = to_string<long>(shlvl_i + 1);
|
||||
}
|
||||
}
|
||||
env_set(L"SHLVL", nshlvl_str.c_str(), ENV_GLOBAL | ENV_EXPORT);
|
||||
env_set(L"SHLVL", ENV_GLOBAL | ENV_EXPORT, nshlvl_str.c_str());
|
||||
env_read_only.insert(L"SHLVL");
|
||||
|
||||
// Set up the HOME variable.
|
||||
|
@ -899,18 +899,18 @@ void env_init(const struct config_paths_t *paths /* or NULL */) {
|
|||
}
|
||||
if (!retval && result && userinfo.pw_dir) {
|
||||
const wcstring dir = str2wcstring(userinfo.pw_dir);
|
||||
env_set(L"HOME", dir.c_str(), ENV_GLOBAL | ENV_EXPORT);
|
||||
env_set(L"HOME", ENV_GLOBAL | ENV_EXPORT, dir.c_str());
|
||||
} else {
|
||||
// We cannot get $HOME, set it to the empty list.
|
||||
// This triggers warnings for history and config.fish already,
|
||||
// so it isn't necessary to warn here as well.
|
||||
env_set(L"HOME", ENV_NULL, ENV_GLOBAL | ENV_EXPORT);
|
||||
env_set(L"HOME", ENV_GLOBAL | ENV_EXPORT, ENV_NULL);
|
||||
}
|
||||
free(unam_narrow);
|
||||
} else {
|
||||
// If $USER is empty as well (which we tried to set above),
|
||||
// we can't get $HOME.
|
||||
env_set(L"HOME", ENV_NULL, ENV_GLOBAL | ENV_EXPORT);
|
||||
env_set(L"HOME", ENV_GLOBAL | ENV_EXPORT, ENV_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -924,7 +924,7 @@ void env_init(const struct config_paths_t *paths /* or NULL */) {
|
|||
use_posix_spawn.missing_or_empty() ? true : from_string<bool>(use_posix_spawn.as_string());
|
||||
|
||||
// Set fish_bind_mode to "default".
|
||||
env_set(FISH_BIND_MODE_VAR, DEFAULT_BIND_MODE, ENV_GLOBAL);
|
||||
env_set(FISH_BIND_MODE_VAR, ENV_GLOBAL, DEFAULT_BIND_MODE);
|
||||
|
||||
// This is somewhat subtle. At this point we consider our environment to be sufficiently
|
||||
// initialized that we can react to changes to variables. Prior to doing this we expect that the
|
||||
|
@ -976,7 +976,7 @@ static env_node_t *env_get_node(const wcstring &key) {
|
|||
/// * ENV_SCOPE, the variable cannot be set in the given scope. This applies to readonly/electric
|
||||
/// variables set from the local or universal scopes, or set as exported.
|
||||
/// * ENV_INVALID, the variable value was invalid. This applies only to special variables.
|
||||
int env_set(const wcstring &key, const wchar_t *val, env_mode_flags_t var_mode) {
|
||||
int env_set(const wcstring &key, env_mode_flags_t var_mode, const wchar_t *val) {
|
||||
ASSERT_IS_MAIN_THREAD();
|
||||
bool has_changed_old = vars_stack().has_changed_exported;
|
||||
int done = 0;
|
||||
|
@ -986,7 +986,7 @@ int env_set(const wcstring &key, const wchar_t *val, env_mode_flags_t var_mode)
|
|||
wcstring val_canonical = val;
|
||||
path_make_canonical(val_canonical);
|
||||
if (val != val_canonical) {
|
||||
return env_set(key, val_canonical.c_str(), var_mode);
|
||||
return env_set(key, var_mode, val_canonical.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1528,9 +1528,9 @@ void env_set_argv(const wchar_t *const *argv) {
|
|||
sb.append(*arg);
|
||||
}
|
||||
|
||||
env_set(L"argv", sb.c_str(), ENV_LOCAL);
|
||||
env_set(L"argv", ENV_LOCAL, sb.c_str());
|
||||
} else {
|
||||
env_set(L"argv", NULL, ENV_LOCAL);
|
||||
env_set(L"argv", ENV_LOCAL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ class env_var_t {
|
|||
/// \param mode An optional scope to search in. All scopes are searched if unset
|
||||
env_var_t env_get(const wcstring &key, env_mode_flags_t mode = ENV_DEFAULT);
|
||||
|
||||
int env_set(const wcstring &key, const wchar_t *val, env_mode_flags_t mode);
|
||||
int env_set(const wcstring &key, env_mode_flags_t mode, const wchar_t *val);
|
||||
|
||||
/// Returns true if the specified key exists. This can't be reliably done using env_get, since
|
||||
/// env_get returns null for 0-element arrays.
|
||||
|
|
|
@ -384,7 +384,7 @@ void internal_exec(job_t *j, const io_chain_t &&all_ios) {
|
|||
shlvl_str = to_string<long>(shlvl - 1);
|
||||
}
|
||||
}
|
||||
env_set(L"SHLVL", shlvl_str.c_str(), ENV_GLOBAL | ENV_EXPORT);
|
||||
env_set(L"SHLVL", ENV_GLOBAL | ENV_EXPORT, shlvl_str.c_str());
|
||||
|
||||
// launch_process _never_ returns.
|
||||
launch_process_nofork(j->processes.front().get());
|
||||
|
|
|
@ -421,7 +421,7 @@ int main(int argc, char **argv) {
|
|||
list.push_back(str2wcstring(*ptr));
|
||||
}
|
||||
auto val = list_to_array_val(list);
|
||||
env_set(L"argv", val->c_str(), ENV_DEFAULT);
|
||||
env_set(L"argv", ENV_DEFAULT, val->c_str());
|
||||
|
||||
const wcstring rel_filename = str2wcstring(file);
|
||||
|
||||
|
|
|
@ -1617,7 +1617,7 @@ static void test_abbreviations(void) {
|
|||
{L"gc", L"git checkout"}, {L"foo", L"bar"}, {L"gx", L"git checkout"},
|
||||
};
|
||||
for (auto it : abbreviations) {
|
||||
int ret = env_set(L"_fish_abbr_" + it.first, it.second.c_str(), ENV_LOCAL);
|
||||
int ret = env_set(L"_fish_abbr_" + it.first, ENV_LOCAL, it.second.c_str());
|
||||
if (ret != 0) err(L"Unable to set abbreviation variable");
|
||||
}
|
||||
|
||||
|
@ -2479,7 +2479,7 @@ static void test_autosuggest_suggest_special() {
|
|||
perform_one_autosuggestion_cd_test(L"cd 'test/autosuggest_test/5", vars, L"foo\"bar/",
|
||||
__LINE__);
|
||||
|
||||
env_set(L"AUTOSUGGEST_TEST_LOC", wd.c_str(), ENV_LOCAL);
|
||||
env_set(L"AUTOSUGGEST_TEST_LOC", ENV_LOCAL, wd.c_str());
|
||||
perform_one_autosuggestion_cd_test(L"cd $AUTOSUGGEST_TEST_LOC/0", vars, L"foobar/", __LINE__);
|
||||
perform_one_autosuggestion_cd_test(L"cd ~/test_autosuggest_suggest_specia", vars, L"l/",
|
||||
__LINE__);
|
||||
|
@ -4255,7 +4255,7 @@ long return_timezone_hour(time_t tstamp, const wchar_t *timezone) {
|
|||
char *str_ptr;
|
||||
size_t n;
|
||||
|
||||
env_set(L"TZ", timezone, ENV_EXPORT);
|
||||
env_set(L"TZ", ENV_EXPORT, timezone);
|
||||
localtime_r(&tstamp, <ime);
|
||||
n = strftime(ltime_str, 3, "%H", <ime);
|
||||
if (n != 2) {
|
||||
|
|
|
@ -340,7 +340,7 @@ void function_prepare_environment(const wcstring &name, const wchar_t *const *ar
|
|||
const wchar_t *const *arg;
|
||||
size_t i;
|
||||
for (i = 0, arg = argv; i < named_arguments.size(); i++) {
|
||||
env_set(named_arguments.at(i).c_str(), *arg, ENV_LOCAL | ENV_USER);
|
||||
env_set(named_arguments.at(i).c_str(), ENV_LOCAL | ENV_USER, *arg);
|
||||
|
||||
if (*arg) arg++;
|
||||
}
|
||||
|
@ -349,6 +349,6 @@ void function_prepare_environment(const wcstring &name, const wchar_t *const *ar
|
|||
for (std::map<wcstring, env_var_t>::const_iterator it = inherited_vars.begin(),
|
||||
end = inherited_vars.end();
|
||||
it != end; ++it) {
|
||||
env_set(it->first, it->second.missing() ? NULL : it->second.c_str(), ENV_LOCAL | ENV_USER);
|
||||
env_set(it->first, ENV_LOCAL | ENV_USER, it->second.missing() ? NULL : it->second.c_str());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -211,7 +211,7 @@ void input_set_bind_mode(const wcstring &bm) {
|
|||
// modes may not be empty - empty is a sentinel value meaning to not change the mode
|
||||
assert(!bm.empty());
|
||||
if (input_get_bind_mode() != bm.c_str()) {
|
||||
env_set(FISH_BIND_MODE_VAR, bm.c_str(), ENV_GLOBAL);
|
||||
env_set(FISH_BIND_MODE_VAR, ENV_GLOBAL, bm.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -473,7 +473,7 @@ parse_execution_result_t parse_execution_context_t::run_for_statement(
|
|||
}
|
||||
|
||||
const wcstring &val = argument_sequence.at(i);
|
||||
env_set(for_var_name, val.c_str(), ENV_LOCAL);
|
||||
env_set(for_var_name, ENV_LOCAL, val.c_str());
|
||||
fb->loop_status = LOOP_NORMAL;
|
||||
|
||||
this->run_job_list(block_contents, fb);
|
||||
|
|
|
@ -260,7 +260,7 @@ static void maybe_issue_path_warning(const wcstring &which_dir, const wcstring &
|
|||
if (env_exist(warning_var_name.c_str(), ENV_GLOBAL | ENV_EXPORT)) {
|
||||
return;
|
||||
}
|
||||
env_set(warning_var_name, L"1", ENV_GLOBAL | ENV_EXPORT);
|
||||
env_set(warning_var_name, ENV_GLOBAL | ENV_EXPORT, L"1");
|
||||
|
||||
debug(0, custom_error_msg.c_str());
|
||||
if (path.empty()) {
|
||||
|
|
|
@ -765,8 +765,8 @@ void reader_init() {
|
|||
|
||||
// Ensure this var is present even before an interactive command is run so that if it is used
|
||||
// in a function like `fish_prompt` or `fish_right_prompt` it is defined at the time the first
|
||||
// prompt is issued.
|
||||
env_set(ENV_CMD_DURATION, L"0", ENV_UNEXPORT);
|
||||
// prompt is written.
|
||||
env_set(ENV_CMD_DURATION, ENV_UNEXPORT, L"0");
|
||||
|
||||
// Save the initial terminal mode.
|
||||
tcgetattr(STDIN_FILENO, &terminal_mode_on_startup);
|
||||
|
@ -1650,7 +1650,7 @@ static void reader_interactive_init() {
|
|||
wperror(L"tcsetattr");
|
||||
}
|
||||
|
||||
env_set(L"_", L"fish", ENV_GLOBAL);
|
||||
env_set(L"_", ENV_GLOBAL, L"fish");
|
||||
}
|
||||
|
||||
/// Destroy data for interactive use.
|
||||
|
@ -1917,7 +1917,7 @@ void set_env_cmd_duration(struct timeval *after, struct timeval *before) {
|
|||
}
|
||||
|
||||
swprintf(buf, 16, L"%d", (secs * 1000) + (usecs / 1000));
|
||||
env_set(ENV_CMD_DURATION, buf, ENV_UNEXPORT);
|
||||
env_set(ENV_CMD_DURATION, ENV_UNEXPORT, buf);
|
||||
}
|
||||
|
||||
void reader_run_command(parser_t &parser, const wcstring &cmd) {
|
||||
|
@ -1925,7 +1925,7 @@ void reader_run_command(parser_t &parser, const wcstring &cmd) {
|
|||
|
||||
wcstring ft = tok_first(cmd);
|
||||
|
||||
if (!ft.empty()) env_set(L"_", ft.c_str(), ENV_GLOBAL);
|
||||
if (!ft.empty()) env_set(L"_", ENV_GLOBAL, ft.c_str());
|
||||
|
||||
reader_write_title(cmd);
|
||||
|
||||
|
@ -1941,7 +1941,7 @@ void reader_run_command(parser_t &parser, const wcstring &cmd) {
|
|||
|
||||
term_steal();
|
||||
|
||||
env_set(L"_", program_name, ENV_GLOBAL);
|
||||
env_set(L"_", ENV_GLOBAL, program_name);
|
||||
|
||||
#ifdef HAVE__PROC_SELF_STAT
|
||||
proc_update_jiffies();
|
||||
|
|
Loading…
Reference in a new issue