diff --git a/builtin_set.c b/builtin_set.c index ab6e7e6ae..5849c7857 100644 --- a/builtin_set.c +++ b/builtin_set.c @@ -28,64 +28,147 @@ Functions used for implementing the set builtin. #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" +#define BUILTIN_SET_ARG_COUNT L"%ls: The number of variable indexes does not match the number of values\n" + +static int is_path_variable( const wchar_t *env ) +{ + return contains_str( env, + L"PATH", + L"CDPATH", + (void *)0 ); +} /** - Call env_set. On error, print a description of the problem to - stderr. + 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 void my_env_set( const wchar_t *key, const wchar_t *val, int scope ) +static int my_env_set( const wchar_t *key, array_list_t *val, int scope ) { + string_buffer_t sb; + int i; + int retcode = 0; + wchar_t *val_str=0; + + if( is_path_variable( key ) ) + { + int error = 0; + + for( i=0; i