mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-04 05:21:13 +08:00
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
This commit is contained in:
parent
b1439075c6
commit
b6e8171f01
@ -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();
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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")
|
||||
|
@ -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: /')"
|
||||
|
Loading…
x
Reference in New Issue
Block a user