diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2012-03-19 11:52:18 -0700 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2012-03-19 11:52:18 -0700 |
commit | 1a87f44325327aff426118da1d9fdf8ac01f67a9 (patch) | |
tree | 309b3e63d6baef111ebab8493b793ac54e7b2720 /builtin_set.cpp | |
parent | c8bc535f22d04f12b34e9722839764dcc9198871 (diff) |
Re-implement $history variable
Added -L option to set to mean "don't abbreviate"
Diffstat (limited to 'builtin_set.cpp')
-rw-r--r-- | builtin_set.cpp | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/builtin_set.cpp b/builtin_set.cpp index 7eec8eb4..a02bc94f 100644 --- a/builtin_set.cpp +++ b/builtin_set.cpp @@ -298,10 +298,10 @@ static void erase_values(wcstring_list_t &list, std::vector<long> &indexes) /** - Print the names of all environment variables in the scope, with or without values, - with or without escaping + Print the names of all environment variables in the scope, with or without shortening, + with or without values, with or without escaping */ -static void print_variables(int include_values, int esc, int scope) +static void print_variables(int include_values, int esc, bool shorten_ok, int scope) { wcstring_list_t names = env_get_names(scope); sort(names.begin(), names.end()); @@ -320,7 +320,7 @@ static void print_variables(int include_values, int esc, int scope) { int shorten = 0; - if( value.length() > 64 ) + if( shorten_ok && value.length() > 64 ) { shorten = 1; value.resize(60); @@ -383,7 +383,11 @@ static int builtin_set( parser_t &parser, wchar_t **argv ) } , { - L"universal", no_argument, 0, 'U' + L"universal", no_argument, 0, 'U' + } + , + { + L"long", no_argument, 0, 'L' } , { @@ -400,7 +404,7 @@ static int builtin_set( parser_t &parser, wchar_t **argv ) } ; - const wchar_t *short_options = L"+xglenuUqh"; + const wchar_t *short_options = L"+xglenuULqh"; int argc = builtin_count_args(argv); @@ -410,7 +414,7 @@ static int builtin_set( parser_t &parser, wchar_t **argv ) int local = 0, global = 0, exportv = 0; int erase = 0, list = 0, unexport=0; int universal = 0, query=0; - + bool shorten_ok = true; /* Variables used for performing the actual work @@ -467,6 +471,10 @@ static int builtin_set( parser_t &parser, wchar_t **argv ) case 'U': universal = 1; break; + + case 'L': + shorten_ok = false; + break; case 'q': query = 1; @@ -574,8 +582,6 @@ static int builtin_set( parser_t &parser, wchar_t **argv ) wcstring_list_t result; size_t j; -// al_init( &result ); -// al_init( &indexes ); env_var_t dest_str = env_get_string(dest); if (! dest_str.missing()) tokenize_variable_array( dest_str, result ); @@ -612,7 +618,7 @@ static int builtin_set( parser_t &parser, wchar_t **argv ) if( list ) { /* Maybe we should issue an error if there are any other arguments? */ - print_variables(0, 0, scope); + print_variables(0, 0, shorten_ok, scope); return 0; } @@ -633,7 +639,7 @@ static int builtin_set( parser_t &parser, wchar_t **argv ) } else { - print_variables( 1, 1, scope ); + print_variables( 1, 1, shorten_ok, scope ); } return retcode; |