aboutsummaryrefslogtreecommitdiffhomepage
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
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
-rw-r--r--builtin_set.c23
-rw-r--r--doc_src/functions.txt2
-rw-r--r--doc_src/set.txt2
-rw-r--r--share/completions/functions.fish1
-rw-r--r--share/completions/set.fish2
5 files changed, 18 insertions, 12 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();
diff --git a/doc_src/functions.txt b/doc_src/functions.txt
index 64294782..7643bfc6 100644
--- a/doc_src/functions.txt
+++ b/doc_src/functions.txt
@@ -11,7 +11,7 @@ This builtin command is used to print or erase functions.
- <code>-d DESCRIPTION</code> or <code>--description=DESCRIPTION</code> change the description of this function
- <code>-e</code> or <code>--erase</code> causes the specified functions to be erased.
- <code>-h</code> or <code>--help</code> display a help message and exit
-- <code>-n</code> or <code>--names</code> list only the names of all defined functions
+- <code>-n</code> or <code>--names</code> list only the names of all defined functions, not their definition
- <code>-q</code> or <code>--query</code> test if the specified functions exist. Does not output anything, but the builtins exit status is the number of functions specified that were not defined.
The default behavior of \c functions when called with no arguments,
diff --git a/doc_src/set.txt b/doc_src/set.txt
index 78d26183..8354dbef 100644
--- a/doc_src/set.txt
+++ b/doc_src/set.txt
@@ -15,7 +15,7 @@ The <code>set</code> builtin causes fish to assign the variable <code>VARIABLE_N
- <code>-l</code> or <code>--local</code> forces the specified environment variable to be given a scope that is local to the current block, even if a variable with the given name exists and is non-local
- <code>-g</code> or <code>--global</code> causes the specified environment variable to be given a global scope. Non-global variables disappear when the block they belong to ends
- <code>-U</code> or <code>--universal</code> causes the specified environment variable to be given a universal scope. If this option is supplied, the variable will be shared between all the current users fish instances on the current computer, and will be preserved across restarts of the shell.
-- <code>-n</code> or <code>--names</code> List only the names of all defined variables
+- <code>-n</code> or <code>--names</code> List only the names of all defined variables, not their value
- <code>-q</code> or <code>--query</code> test if the specified variable names are defined. Does not output anything, but the builtins exit status is the number of variables specified that were not defined.
- <code>-u</code> or <code>--unexport</code> causes the specified environment not to be exported to child processes
- <code>-x</code> or <code>--export</code> causes the specified environment variable to be exported to child processes
diff --git a/share/completions/functions.fish b/share/completions/functions.fish
index e614ed39..738ba747 100644
--- a/share/completions/functions.fish
+++ b/share/completions/functions.fish
@@ -4,3 +4,4 @@ complete -c functions -s a -l all -d (N_ "Show hidden functions")
complete -c functions -s h -l help -d (N_ "Display help and exit")
complete -c functions -s d -l description -d (N_ "Set function description") -x
complete -c functions -s q -l query -d (N_ "Test if function is defined")
+complete -c functions -s n -l names -d (N_ "List the names of the functions, but not their definition")
diff --git a/share/completions/set.fish b/share/completions/set.fish
index 1510fbc7..6526c501 100644
--- a/share/completions/set.fish
+++ b/share/completions/set.fish
@@ -63,6 +63,8 @@ complete -c set -n '__fish_is_first_token' -s l -l local -d (N_ "Make variable s
complete -c set -n '__fish_is_first_token' -s U -l universal -d (N_ "Make variable scope universal, i.e. share variable with all the users fish processes on this computer")
complete -c set -n '__fish_is_first_token' -s q -l query -d (N_ "Test if variable is defined")
complete -c set -n '__fish_is_first_token' -s h -l help -d (N_ "Display help and exit")
+complete -c set -n '__fish_is_first_token' -s n -l names -d (N_ "List the names of the variables, but not their value")
+
# Complete using preexisting variable names
complete -c set -n '__fish_is_first_token' -x -a "(set|sed -e 's/ /'\t'Variable: /')"