From 06668bfacbc934598a1bc6ed25f6c1dcb5070064 Mon Sep 17 00:00:00 2001 From: axel Date: Wed, 10 May 2006 02:40:55 +1000 Subject: [PATCH] Alter syntax for set builtin so that better slicing operations are possible darcs-hash:20060509164055-ac50b-8514b73bb9e992c463966f95f783f01893ba93bd.gz --- builtin_set.c | 600 ++++++++++++++++++++++++++------------------------ 1 file changed, 307 insertions(+), 293 deletions(-) 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