darcs-hash:20051207155717-ac50b-6146b02bd8aff0fd27816acd5e31b38093d8575d.gz
This commit is contained in:
axel 2005-12-08 01:57:17 +10:00
parent a46be4cadb
commit 0c877183b9
10 changed files with 52 additions and 52 deletions

View file

@ -1971,7 +1971,7 @@ void complete( const wchar_t *cmd,
error_max=0; error_max=0;
/** /**
If we are completing a variable name or a tilde expantion user If we are completing a variable name or a tilde expansion user
name, we do that and return. No need for any other competions. name, we do that and return. No need for any other competions.
*/ */

View file

@ -16,7 +16,7 @@ the user does not have to worry about an array containing elements
such as dashes. \c fish performs a special check when invoking the such as dashes. \c fish performs a special check when invoking the
count program, and if the user uses a help option, this help page is count program, and if the user uses a help option, this help page is
displayed, but if a help option is contained inside of a variable or displayed, but if a help option is contained inside of a variable or
is the result of expantion, it will be passed on to the count program. is the result of expansion, it will be passed on to the count program.
\subsection count-example Example \subsection count-example Example

View file

@ -68,7 +68,7 @@ and <a href="#escapes">character escapes</a> get in the way. When that
happens, the user can write a parameter within quotes, either ' happens, the user can write a parameter within quotes, either '
(single quote) or " (double quote). There is one important difference (single quote) or " (double quote). There is one important difference
between single quoted and double quoted strings: When using double between single quoted and double quoted strings: When using double
quoted string, <a href='#expand-variable'>variable expantion</a> still quoted string, <a href='#expand-variable'>variable expansion</a> still
takes place. Other than that, a quoted parameter will not be takes place. Other than that, a quoted parameter will not be
parameter expanded, may contain spaces, and escape sequences are parameter expanded, may contain spaces, and escape sequences are
ignored. Single quotes have no special meaning withing double quotes ignored. Single quotes have no special meaning withing double quotes
@ -283,8 +283,8 @@ the \c -a switch. If \c myprog accepts the arguments start and stop,
this can be specified as <tt>complete -c myprog -a 'start this can be specified as <tt>complete -c myprog -a 'start
stop'</tt>. The argument to the \c -a switch is always a single stop'</tt>. The argument to the \c -a switch is always a single
string. At completion time, it will be tokenized on spaces and tabs, string. At completion time, it will be tokenized on spaces and tabs,
and variable expantion, command substitution and other forms of and variable expansion, command substitution and other forms of
parameter expantion will take place. parameter expansion will take place.
Fish has a special syntax to support specifying switches accepted by a Fish has a special syntax to support specifying switches accepted by a
command. The switches \c -s, \c -l and \c -o are used to specify a command. The switches \c -s, \c -l and \c -o are used to specify a
@ -319,7 +319,7 @@ href='mailto: fish-users@lists.sf.net'>the fish mailinglist</a>.
\section expand Parameter expansion (Globbing) \section expand Parameter expansion (Globbing)
When an argument for a program is given on the commandline, it When an argument for a program is given on the commandline, it
undergoes the process of parameter expantion before it is sent on to undergoes the process of parameter expansion before it is sent on to
the command. There are many ways in which the user can specify a the command. There are many ways in which the user can specify a
parameter to be expanded. These include: parameter to be expanded. These include:
@ -344,7 +344,7 @@ warning will also be printed.
\subsection expand-command-substitution Command substitution \subsection expand-command-substitution Command substitution
If a parameter contains a set of parenthesis, the text enclosed by the If a parameter contains a set of parenthesis, the text enclosed by the
parentesis will be interpreted as a list of commands. Om expantion, parentesis will be interpreted as a list of commands. Om expansion,
this list is executed, and substituted by the output. If the output is this list is executed, and substituted by the output. If the output is
more than one line long, each line will be expanded to a new more than one line long, each line will be expanded to a new
parameter. parameter.
@ -393,27 +393,27 @@ shells allow you to specify a variable name using '$VARNAME' or
'${VARNAME}'. Fish only supports the former, but has no support '${VARNAME}'. Fish only supports the former, but has no support
whatsoever for the latter or anything remotely like it. So what is whatsoever for the latter or anything remotely like it. So what is
'{$VARNAME}' then? Well, '{WHATEVER}' is <a href='#brace'>brace '{$VARNAME}' then? Well, '{WHATEVER}' is <a href='#brace'>brace
expantion</a>, the same as supported by Posix shells, i.e. 'a{b,c}d' expansion</a>, the same as supported by Posix shells, i.e. 'a{b,c}d'
-> 'abd acd' works both in bash and on fish. So '{$VARNAME}' is a -> 'abd acd' works both in bash and on fish. So '{$VARNAME}' is a
bracket-expantion with only a single element, i.e. it becomes bracket-expansion with only a single element, i.e. it becomes
expanded to '$VARNAME', which will be variable expanded to the value expanded to '$VARNAME', which will be variable expanded to the value
of the variable 'VARNAME'. So you might think that the brackets don't of the variable 'VARNAME'. So you might think that the brackets don't
actually do anything, and that is nearly the truth. The snag is that actually do anything, and that is nearly the truth. The snag is that
there once along the way was a '}' in there somewhere, and } is not a there once along the way was a '}' in there somewhere, and } is not a
valid character in a variable name. So anything after the otherwise valid character in a variable name. So anything after the otherwise
pointless bracket expantion becomes NOT a part of the variable name, pointless bracket expansion becomes NOT a part of the variable name,
even if it happens to be a legal variable name character. That's why even if it happens to be a legal variable name character. That's why
'{$USER}san' works. A case of one syntax just lending itself so nicely '{$USER}san' works. A case of one syntax just lending itself so nicely
to solving an unrelated problem in it's spare time. to solving an unrelated problem in it's spare time.
Variable expantion is the only type of expantion performed on double Variable expansion is the only type of expansion performed on double
quoted strings. There is, however, an important difference in how quoted strings. There is, however, an important difference in how
variables are expanded when quoted and when unquoted. An unquoted variables are expanded when quoted and when unquoted. An unquoted
variable expantion will result in a variable number of arguments. For variable expansion will result in a variable number of arguments. For
example, if the variable $foo has zero elements or is undefined, the example, if the variable $foo has zero elements or is undefined, the
argument $foo will expand to zero elements. If the variable $foo is an argument $foo will expand to zero elements. If the variable $foo is an
array of five elements, the argument $foo will expand to five array of five elements, the argument $foo will expand to five
elements. When quoted, like "$foo", a variable expantion will always elements. When quoted, like "$foo", a variable expansion will always
result in exactly one argument. Undefined variables will expand to the result in exactly one argument. Undefined variables will expand to the
empty string, and array variables will be concatenated using the space empty string, and array variables will be concatenated using the space
character. character.
@ -429,7 +429,7 @@ directory of the process owner.
\subsection expand-process Process expansion \subsection expand-process Process expansion
The \% (percent) character at the beginning of a parameter followed by The \% (percent) character at the beginning of a parameter followed by
a string is expanded into a process id. The following expantions are a string is expanded into a process id. The following expansions are
performed: performed:
- If the string is the entire word \c self, the shells pid is the result - If the string is the entire word \c self, the shells pid is the result
@ -471,7 +471,7 @@ The concept of environment variables are central to any
shell. Environment variables are variables, whose values can be set shell. Environment variables are variables, whose values can be set
and used by the user. For information on how to use the current value and used by the user. For information on how to use the current value
of a variable, see the section on <a href='#expand-variable'>variable of a variable, see the section on <a href='#expand-variable'>variable
expantion</a>. expansion</a>.
To set a variable value, use the <a href="builtins.html#set"> \c set To set a variable value, use the <a href="builtins.html#set"> \c set
command</a>. command</a>.
@ -1159,7 +1159,7 @@ language will often be rather low-level.
Examples: Examples:
- There should only be one type of input to the shell, lists of commands. Loops, conditionals and variable assignments are all performed through regular commands. - There should only be one type of input to the shell, lists of commands. Loops, conditionals and variable assignments are all performed through regular commands.
- The differences between builtin commands, shellscript functions and builtin commands should be made as small as possible. Builtins and shellscript functions should have exactly the same types of argument expantion as other commands, should be possible to use in any position in a pipeline, and should support any io redirection. - The differences between builtin commands, shellscript functions and builtin commands should be made as small as possible. Builtins and shellscript functions should have exactly the same types of argument expansion as other commands, should be possible to use in any position in a pipeline, and should support any io redirection.
- Instead of forking when performing command substitution to provide a fake variable scope, all fish commands are performed from the same process, and fish instead supports true scoping - Instead of forking when performing command substitution to provide a fake variable scope, all fish commands are performed from the same process, and fish instead supports true scoping
- All blocks end with the \c end builtin - All blocks end with the \c end builtin

View file

@ -68,7 +68,7 @@ parameter expansion.
#define COMPLETE_LAST_DESC COMPLETE_SEP_STR L"Last background job" #define COMPLETE_LAST_DESC COMPLETE_SEP_STR L"Last background job"
#define COMPLETE_VAR_DESC L"Variable name is zero characters long." #define COMPLETE_VAR_DESC L"Variable name is zero characters long."
#define COMPLETE_VAR2_DESC L" Did you mean {$VARIABLE}? For information on how variable expantion in fish differs from Posix variable expantion, see the manual section on variable expantion by typing 'help expand-variable'." #define COMPLETE_VAR2_DESC L" Did you mean {$VARIABLE}? For information on how variable expansion in fish differs from Posix variable expansion, see the manual section on variable expansion by typing 'help expand-variable'."
/** /**
String in process expansion denoting ourself String in process expansion denoting ourself
@ -95,8 +95,8 @@ parameter expansion.
any tokens which need to be expanded or otherwise altered. Clean any tokens which need to be expanded or otherwise altered. Clean
strings can be passed through expand_string and expand_one without strings can be passed through expand_string and expand_one without
changing them. About 90% of all strings are clean, so skipping changing them. About 90% of all strings are clean, so skipping
expantion on them actually does save a small amount of time, since expansion on them actually does save a small amount of time, since
it avoids multiple memory allocations during the expantion process. it avoids multiple memory allocations during the expansion process.
*/ */
static int is_clean( const wchar_t *in ) static int is_clean( const wchar_t *in )
{ {
@ -918,14 +918,14 @@ static int expand_variables( wchar_t *in, array_list_t *out )
if( c == VARIABLE_EXPAND ) if( c == VARIABLE_EXPAND )
{ {
/* /*
Regular expantion, i.e. expand this argument to nothing Regular expansion, i.e. expand this argument to nothing
*/ */
empty = 1; empty = 1;
} }
else else
{ {
/* /*
Expantion to single argument. Expansion to single argument.
*/ */
string_buffer_t res; string_buffer_t res;
sb_init( &res ); sb_init( &res );
@ -1404,7 +1404,7 @@ static void remove_internal_separator( const void *s, int conv )
/** /**
The real expantion function. expand_one is just a wrapper around this one. The real expansion function. expand_one is just a wrapper around this one.
*/ */
int expand_string( wchar_t *str, int expand_string( wchar_t *str,
array_list_t *end_out, array_list_t *end_out,
@ -1533,7 +1533,7 @@ int expand_string( wchar_t *str,
if( *next == PROCESS_EXPAND ) if( *next == PROCESS_EXPAND )
{ {
/* /*
If process expantion matches, we are not If process expansion matches, we are not
interested in other completions, so we interested in other completions, so we
short-circut and return short-circut and return
*/ */

View file

@ -1,7 +1,7 @@
/**\file expand.h /**\file expand.h
Prototypes for string expantion functions. These functions perform Prototypes for string expansion functions. These functions perform
several kinds of parameter expantion. There are a lot of issues several kinds of parameter expansion. There are a lot of issues
with regards to memory allocation. Overall, these functions would with regards to memory allocation. Overall, these functions would
benefit from using a more clever memory allocation scheme, perhaps benefit from using a more clever memory allocation scheme, perhaps
an evil combination of talloc, string buffers and reference an evil combination of talloc, string buffers and reference
@ -20,17 +20,17 @@
#include "util.h" #include "util.h"
/** /**
Flag specifying that subshell expantion should be skipped Flag specifying that subshell expansion should be skipped
*/ */
#define EXPAND_SKIP_SUBSHELL 1 #define EXPAND_SKIP_SUBSHELL 1
/** /**
Flag specifying that variable expantion should be skipped Flag specifying that variable expansion should be skipped
*/ */
#define EXPAND_SKIP_VARIABLES 2 #define EXPAND_SKIP_VARIABLES 2
/** /**
Flag specifying that wildcard expantion should be skipped Flag specifying that wildcard expansion should be skipped
*/ */
#define EXPAND_SKIP_WILDCARDS 4 #define EXPAND_SKIP_WILDCARDS 4
@ -64,19 +64,19 @@ enum
/** Character represeting a home directory */ /** Character represeting a home directory */
HOME_DIRECTORY = EXPAND_RESERVED, HOME_DIRECTORY = EXPAND_RESERVED,
/** Character represeting process expantion */ /** Character represeting process expansion */
PROCESS_EXPAND, PROCESS_EXPAND,
/** Character representing variable expantion */ /** Character representing variable expansion */
VARIABLE_EXPAND, VARIABLE_EXPAND,
/** Character rpresenting variable expantion into a single element*/ /** Character rpresenting variable expansion into a single element*/
VARIABLE_EXPAND_SINGLE, VARIABLE_EXPAND_SINGLE,
/** Character representing the start of a bracket expantion */ /** Character representing the start of a bracket expansion */
BRACKET_BEGIN, BRACKET_BEGIN,
/** Character representing the end of a bracket expantion */ /** Character representing the end of a bracket expansion */
BRACKET_END, BRACKET_END,
/** Character representing separation between two bracket elements */ /** Character representing separation between two bracket elements */
@ -118,7 +118,7 @@ enum
Perform various forms of expansion on in, such as tilde expansion Perform various forms of expansion on in, such as tilde expansion
(~USER becomes the users home directory), variable expansion (~USER becomes the users home directory), variable expansion
($VAR_NAME becomes the value of the environment variable VAR_NAME), ($VAR_NAME becomes the value of the environment variable VAR_NAME),
subshell expantion and wildcard expansion. The results are inserted subshell expansion and wildcard expansion. The results are inserted
into the list out. into the list out.
If the parameter does not need expansion, it is copied into the list If the parameter does not need expansion, it is copied into the list
@ -126,7 +126,7 @@ enum
newly allocated strings are inserted into the list out. newly allocated strings are inserted into the list out.
\param in The parameter to expand \param in The parameter to expand
\param flag Specifies if any expantion pass should be skipped. Legal values are any combination of EXPAND_SKIP_SUBSHELL EXPAND_SKIP_VARIABLES and EXPAND_SKIP_WILDCARDS \param flag Specifies if any expansion pass should be skipped. Legal values are any combination of EXPAND_SKIP_SUBSHELL EXPAND_SKIP_VARIABLES and EXPAND_SKIP_WILDCARDS
\param out The list to which the result will be appended. \param out The list to which the result will be appended.
\return One of EXPAND_OK, EXPAND_ERROR, EXPAND_WILDCARD_MATCH and EXPAND_WILDCARD_NO_MATCH \return One of EXPAND_OK, EXPAND_ERROR, EXPAND_WILDCARD_MATCH and EXPAND_WILDCARD_NO_MATCH
*/ */
@ -138,7 +138,7 @@ int expand_string( wchar_t *in, array_list_t *out, int flag );
names. names.
\param in The parameter to expand \param in The parameter to expand
\param flag Specifies if any expantion pass should be skipped. Legal values are any combination of EXPAND_SKIP_SUBSHELL EXPAND_SKIP_VARIABLES and EXPAND_SKIP_WILDCARDS \param flag Specifies if any expansion pass should be skipped. Legal values are any combination of EXPAND_SKIP_SUBSHELL EXPAND_SKIP_VARIABLES and EXPAND_SKIP_WILDCARDS
\return The expanded parameter, or 0 on failiure \return The expanded parameter, or 0 on failiure
*/ */
wchar_t *expand_one( wchar_t *in, int flag ); wchar_t *expand_one( wchar_t *in, int flag );
@ -175,9 +175,9 @@ wchar_t *expand_escape_variable( const wchar_t *in );
/** /**
Perform tilde expantion and nothing else on the specified string. Perform tilde expansion and nothing else on the specified string.
If tilde expantion is needed, the original string is freed and a If tilde expansion is needed, the original string is freed and a
new string, allocated using malloc, is returned. new string, allocated using malloc, is returned.
*/ */
wchar_t *expand_tilde(wchar_t *in); wchar_t *expand_tilde(wchar_t *in);

View file

@ -518,7 +518,7 @@ static void test_parser()
} }
/** /**
Perform parameter expantion and test if the output equals the zero-terminated parameter list supplied. Perform parameter expansion and test if the output equals the zero-terminated parameter list supplied.
\param in the string to expand \param in the string to expand
\param flags the flags to send to expand_string \param flags the flags to send to expand_string
@ -561,11 +561,11 @@ static int expand_test( const wchar_t *in, int flags, ... )
} }
/** /**
Test globbing and other parameter expantion Test globbing and other parameter expansion
*/ */
static void test_expand() static void test_expand()
{ {
say( L"Testing parameter expantion" ); say( L"Testing parameter expansion" );
if( !expand_test( L"foo", 0, L"foo", 0 )) if( !expand_test( L"foo", 0, L"foo", 0 ))
{ {
@ -574,12 +574,12 @@ static void test_expand()
if( !expand_test( L"a{b,c,d}e", 0, L"abe", L"ace", L"ade", 0 ) ) if( !expand_test( L"a{b,c,d}e", 0, L"abe", L"ace", L"ade", 0 ) )
{ {
err( L"Bracket expantion is broken" ); err( L"Bracket expansion is broken" );
} }
if( !expand_test( L"a*", EXPAND_SKIP_WILDCARDS, L"a*", 0 ) ) if( !expand_test( L"a*", EXPAND_SKIP_WILDCARDS, L"a*", 0 ) )
{ {
err( L"Cannot skip wildcard expantion" ); err( L"Cannot skip wildcard expansion" );
} }
} }

View file

@ -22,7 +22,6 @@ complete -c help -x -a prompt -d "Help on how to set the prompt"
complete -c help -x -a title -d "Help on how to set the titlebar message" complete -c help -x -a title -d "Help on how to set the titlebar message"
complete -c help -x -a killring -d "Help on how to copy and paste" complete -c help -x -a killring -d "Help on how to copy and paste"
complete -c help -x -a editor -d "Help on editor shortcuts" complete -c help -x -a editor -d "Help on editor shortcuts"
complete -c help -x -a globbing -d "Help on parameter expantion (Globbing)"
complete -c help -x -a variables -d "Help on environment variables" complete -c help -x -a variables -d "Help on environment variables"
complete -c help -x -a color -d "Help on setting syntax highlighting colors" complete -c help -x -a color -d "Help on setting syntax highlighting colors"
complete -c help -x -a prompt -d "Help on changing the prompt" complete -c help -x -a prompt -d "Help on changing the prompt"
@ -30,10 +29,11 @@ complete -c help -x -a title -d "Help on changing the titlebar messages"
complete -c help -x -a builtin-overview -d "A short summary of all builtin commands" complete -c help -x -a builtin-overview -d "A short summary of all builtin commands"
complete -c help -x -a changes -d "The changelog" complete -c help -x -a changes -d "The changelog"
complete -c help -x -a expand -d "Help on parameter expantion (Globbing)" complete -c help -x -a globbing -d "Help on parameter expansion (Globbing)"
complete -c help -x -a expand -d "Help on parameter expansion (Globbing)"
complete -c help -x -a expand-variable -d "Help on variable exapantion \$VARNAME" complete -c help -x -a expand-variable -d "Help on variable exapantion \$VARNAME"
complete -c help -x -a expand-home -d "Help on home directory expantion ~USER" complete -c help -x -a expand-home -d "Help on home directory expansion ~USER"
complete -c help -x -a expand-brace -d "Help on brace expantion {a,b,c}" complete -c help -x -a expand-brace -d "Help on brace expansion {a,b,c}"
complete -c help -x -a expand-wildcard -d "Help on wildcard expantion *.*" complete -c help -x -a expand-wildcard -d "Help on wildcard expansion *.*"
complete -c help -x -a expand-command-substitution -d "Help on command substututions (SUBCOMMAND)" complete -c help -x -a expand-command-substitution -d "Help on command substututions (SUBCOMMAND)"
complete -c help -x -a expand-process -d "Help on process expantion %JOB" complete -c help -x -a expand-process -d "Help on process expansion %JOB"

View file

@ -1005,3 +1005,4 @@ function delete-or-exit --key-binding
exit exit
end end
end end

View file

@ -307,7 +307,7 @@ void get_desc( wchar_t *fn, string_buffer_t *sb, int is_cmd )
/* /*
Test if the file specified by the given filename matches the Test if the file specified by the given filename matches the
expantion flags specified. flags can be a combination of expansion flags specified. flags can be a combination of
EXECUTABLES_ONLY and DIRECTORIES_ONLY. EXECUTABLES_ONLY and DIRECTORIES_ONLY.
*/ */
static int test_flags( wchar_t *filename, static int test_flags( wchar_t *filename,

View file

@ -1,8 +1,7 @@
/** \file wildcard.h /** \file wildcard.h
My own globbing implementation. Needed to implement this instead My own globbing implementation. Needed to implement this instead
of using libs globbing to support tab-expantion of globbed of using libs globbing to support tab-expansion of globbed
paramaters. paramaters.
*/ */