mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-27 16:51:15 -03:00
fix bug in env_get() involving empty vars
My previous change to eliminate `class var_entry_t` caused me to notice that `env_get()` turned a set but empty var into a missing var. Which is wrong. Fixing that brought to light several other pieces of code that were wrong as a consequence of the aforementioned bug. Another step to fixing issue #4200.
This commit is contained in:
@@ -645,8 +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 == ENV_NULL ? NULL : val->c_str(),
|
||||
ENV_LOCAL);
|
||||
env_set(var_name_prefix + opt_spec->short_flag, val->c_str(), ENV_LOCAL);
|
||||
}
|
||||
if (!opt_spec->long_flag.empty()) {
|
||||
// We do a simple replacement of all non alphanum chars rather than calling
|
||||
@@ -655,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 == ENV_NULL ? NULL : val->c_str(), ENV_LOCAL);
|
||||
env_set(var_name_prefix + long_flag, val->c_str(), ENV_LOCAL);
|
||||
}
|
||||
}
|
||||
|
||||
auto val = list_to_array_val(opts.argv);
|
||||
env_set(L"argv", *val == ENV_NULL ? NULL : val->c_str(), ENV_LOCAL);
|
||||
env_set(L"argv", val->c_str(), ENV_LOCAL);
|
||||
}
|
||||
|
||||
/// The argparse builtin. This is explicitly not compatible with the BSD or GNU version of this
|
||||
|
||||
Reference in New Issue
Block a user