@@ -212,7 +212,7 @@ static int validate_cmd_opts(const wchar_t *cmd, set_cmd_opts_t &opts, //!OCLIN
212
212
static int check_global_scope_exists (const wchar_t *cmd, set_cmd_opts_t &opts, const wchar_t *dest,
213
213
io_streams_t &streams) {
214
214
if (opts.universal ) {
215
- env_var_t global_dest = env_get_string (dest, ENV_GLOBAL);
215
+ env_var_t global_dest = env_get (dest, ENV_GLOBAL);
216
216
if (!global_dest.missing ()) {
217
217
streams.err .append_format (
218
218
_ (L" %ls: Warning: universal scope selected, but a global variable '%ls' exists.\n " ),
@@ -239,9 +239,8 @@ static int my_env_path_setup(const wchar_t *cmd, const wchar_t *key, //!OCLINT(
239
239
// not the (missing) local value. Also don't bother to complain about relative paths, which
240
240
// don't start with /.
241
241
wcstring_list_t existing_values;
242
- const env_var_t existing_variable = env_get_string (key, ENV_DEFAULT);
243
- if (!existing_variable.missing_or_empty ())
244
- tokenize_variable_array (existing_variable, existing_values);
242
+ const env_var_t existing_variable = env_get (key, ENV_DEFAULT);
243
+ if (!existing_variable.missing_or_empty ()) existing_variable.to_list (existing_values);
245
244
246
245
for (size_t i = 0 ; i < list.size (); i++) {
247
246
const wcstring &dir = list.at (i);
@@ -346,9 +345,9 @@ static int parse_index(std::vector<long> &indexes, wchar_t *src, int scope, io_s
346
345
*p = L' \0 ' ; // split the var name from the indexes/slices
347
346
p++;
348
347
349
- env_var_t var_str = env_get_string (src, scope);
348
+ env_var_t var_str = env_get (src, scope);
350
349
wcstring_list_t var;
351
- if (!var_str.missing ()) tokenize_variable_array ( var_str, var);
350
+ if (!var_str.missing ()) var_str. to_list ( var);
352
351
353
352
int count = 0 ;
354
353
@@ -457,15 +456,16 @@ static int builtin_set_list(const wchar_t *cmd, set_cmd_opts_t &opts, int argc,
457
456
streams.out .append (e_key);
458
457
459
458
if (!names_only) {
460
- env_var_t value = env_get_string (key, compute_scope (opts));
461
- if (!value .missing ()) {
459
+ env_var_t var = env_get (key, compute_scope (opts));
460
+ if (!var .missing ()) {
462
461
bool shorten = false ;
463
- if (opts.shorten_ok && value.length () > 64 ) {
462
+ wcstring val = var.as_string ();
463
+ if (opts.shorten_ok && val.length () > 64 ) {
464
464
shorten = true ;
465
- value .resize (60 );
465
+ val .resize (60 );
466
466
}
467
467
468
- wcstring e_value = expand_escape_variable (value );
468
+ wcstring e_value = expand_escape_variable (val );
469
469
streams.out .append (L" " );
470
470
streams.out .append (e_value);
471
471
@@ -500,8 +500,8 @@ static int builtin_set_query(const wchar_t *cmd, set_cmd_opts_t &opts, int argc,
500
500
501
501
if (idx_count) {
502
502
wcstring_list_t result;
503
- env_var_t dest_str = env_get_string (dest, scope);
504
- if (!dest_str.missing ()) tokenize_variable_array ( dest_str, result);
503
+ env_var_t dest_str = env_get (dest, scope);
504
+ if (!dest_str.missing ()) dest_str. to_list ( result);
505
505
506
506
for (auto idx : indexes) {
507
507
if (idx < 1 || (size_t )idx > result.size ()) retval++;
@@ -538,12 +538,12 @@ static void show_scope(const wchar_t *var_name, int scope, io_streams_t &streams
538
538
}
539
539
540
540
if (env_exist (var_name, scope)) {
541
- const env_var_t evar = env_get_string (var_name, scope | ENV_EXPORT | ENV_USER);
541
+ const env_var_t evar = env_get (var_name, scope | ENV_EXPORT | ENV_USER);
542
542
const wchar_t *exportv = evar.missing () ? _ (L" unexported" ) : _ (L" exported" );
543
543
544
- const env_var_t var = env_get_string (var_name, scope | ENV_USER);
544
+ const env_var_t var = env_get (var_name, scope | ENV_USER);
545
545
wcstring_list_t result;
546
- if (!var.empty ()) tokenize_variable_array ( var, result);
546
+ if (!var.empty ()) var. to_list ( result);
547
547
548
548
streams.out .append_format (_ (L" $%ls: set in %ls scope, %ls, with %d elements\n " ), var_name,
549
549
scope_name, exportv, result.size ());
@@ -632,10 +632,10 @@ static int builtin_set_erase(const wchar_t *cmd, set_cmd_opts_t &opts, int argc,
632
632
if (idx_count == 0 ) { // unset the var
633
633
retval = env_remove (dest, scope);
634
634
} else { // remove just the specified indexes of the var
635
- const env_var_t dest_var = env_get_string (dest, scope);
635
+ const env_var_t dest_var = env_get (dest, scope);
636
636
if (dest_var.missing ()) return STATUS_CMD_ERROR;
637
637
wcstring_list_t result;
638
- tokenize_variable_array ( dest_var, result);
638
+ dest_var. to_list ( result);
639
639
erase_values (result, indexes);
640
640
retval = my_env_set (cmd, dest, result, scope, streams);
641
641
}
@@ -658,9 +658,9 @@ static int set_var_array(const wchar_t *cmd, set_cmd_opts_t &opts, const wchar_t
658
658
for (int i = 0 ; i < argc; i++) new_values.push_back (argv[i]);
659
659
}
660
660
661
- env_var_t var_str = env_get_string (varname, scope);
661
+ env_var_t var_str = env_get (varname, scope);
662
662
wcstring_list_t var_array;
663
- if (!var_str.missing ()) tokenize_variable_array ( var_str, var_array);
663
+ if (!var_str.missing ()) var_str. to_list ( var_array);
664
664
new_values.insert (new_values.end (), var_array.begin (), var_array.end ());
665
665
666
666
if (opts.append ) {
@@ -691,8 +691,8 @@ static int set_var_slices(const wchar_t *cmd, set_cmd_opts_t &opts, const wchar_
691
691
}
692
692
693
693
int scope = compute_scope (opts); // calculate the variable scope based on the provided options
694
- const env_var_t var_str = env_get_string (varname, scope);
695
- if (!var_str.missing ()) tokenize_variable_array ( var_str, new_values);
694
+ const env_var_t var_str = env_get (varname, scope);
695
+ if (!var_str.missing ()) var_str. to_list ( new_values);
696
696
697
697
// Slice indexes have been calculated, do the actual work.
698
698
wcstring_list_t result;
0 commit comments