diff --git a/builtin_set.c b/builtin_set.c index ff33da4a9..9c655309a 100644 --- a/builtin_set.c +++ b/builtin_set.c @@ -26,12 +26,16 @@ Functions used for implementing the set builtin. #include "parser.h" #include "translate.h" +#define BUILTIN_SET_PATH_ERROR L"%ls: Could not add component %ls to %ls.\n" +#define BUILTIN_SET_PATH_HINT L"%ls: Did you mean 'set %ls $%ls %ls'?\n" + /** Call env_set. On error, print a description of the problem to stderr. */ static void my_env_set( const wchar_t *key, const wchar_t *val, int scope ) { + switch( env_set( key, val, scope | ENV_USER ) ) { case ENV_PERM: @@ -265,6 +269,17 @@ static void print_variables(int include_values, int esc, int scope) al_destroy(&names); } +static int is_path_variable( const wchar_t *env ) +{ + return contains_str( env, + L"PATH", + L"CDPATH", + L"fish_function_path", + L"fish_completion_path", + (void *)0 ); +} + + /** The set builtin. Creates, updates and erases environment variables and environemnt variable arrays. */ @@ -478,6 +493,80 @@ int builtin_set( wchar_t **argv ) al_push(&values, argv[woptind++]); } + if( is_path_variable( dest ) ) + { + int i; + int error = 0; + + for( i=0; i