aboutsummaryrefslogtreecommitdiffhomepage
path: root/builtin_set.c
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2006-09-01 01:44:00 +1000
committerGravatar axel <axel@liljencrantz.se>2006-09-01 01:44:00 +1000
commitb6e8171f013e9fe1ae48fd16d56fdda4d872b626 (patch)
tree5ce560765f7fabb7cc0c5bc6d4455970bc3332ba /builtin_set.c
parentb1439075c6c6691d7b595f949391e5f4d5947ad7 (diff)
Fix minor null pointer bug in the set builtin, fix bug causing the -n switch to be ignored, add missing completions for the -n switch to functions and set builtins, and touch up the documentation for said builtin a bit
darcs-hash:20060831154400-ac50b-dddbee79481e0e0a8da9fc025e8a15c466460a2f.gz
Diffstat (limited to 'builtin_set.c')
-rw-r--r--builtin_set.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/builtin_set.c b/builtin_set.c
index 7d7f8379..fc32cb39 100644
--- a/builtin_set.c
+++ b/builtin_set.c
@@ -366,9 +366,12 @@ static void print_variables(int include_values, int esc, int scope)
{
wchar_t *value = env_get(key);
wchar_t *e_value;
- e_value = esc ? expand_escape_variable(value) : wcsdup(value);
- sb_append2(sb_out, L" ", e_value, (void *)0);
- free(e_value);
+ if( value )
+ {
+ e_value = esc ? expand_escape_variable(value) : wcsdup(value);
+ sb_append2(sb_out, L" ", e_value, (void *)0);
+ free(e_value);
+ }
}
sb_append(sb_out, L"\n");
@@ -601,6 +604,13 @@ static int builtin_set( wchar_t **argv )
return retcode;
}
+ if( list )
+ {
+ /* Maybe we should issue an error if there are any other arguments? */
+ print_variables(0, 0, scope);
+ return 0;
+ }
+
if( woptind == argc )
{
/*
@@ -625,13 +635,6 @@ static int builtin_set( wchar_t **argv )
return retcode;
}
- if( list )
- {
- /* Maybe we should issue an error if there are any other arguments? */
- print_variables(0, 0, scope);
- return 0;
- }
-
if( !(dest = wcsdup(argv[woptind])))
{
DIE_MEM();