#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
#include <string.h>
#include <wctype.h>
#include <errno.h>
#include <pwd.h>
#include <unistd.h>
#include <sys/types.h>
#include <termios.h>
#include <dirent.h>
#include <sys/stat.h>
#include <signal.h>
#include <assert.h>
#include "fallback.h"
#include "util.h"
#include "common.h"
#include "wutil.h"
#include "env.h"
#include "proc.h"
#include "parser.h"
#include "expand.h"
#include "wildcard.h"
#include "exec.h"
#include "tokenizer.h"
#include "complete.h"
#include "parse_util.h"
#include "halloc.h"
#include "halloc_util.h"
Defines | |
| #define | COMPLETE_VAR_DESC _( L"The '$' character begins a variable name. The character '%lc', which directly followed a '$', is not allowed as a part of a variable name, and variable names may not be zero characters long. To learn more about variable expansion in fish, type 'help expand-variable'.") |
| Error issued on invalid variable name. | |
| #define | COMPLETE_VAR_NULL_DESC _( L"The '$' begins a variable name. It was given at the end of an argument. Variable names may not be zero characters long. To learn more about variable expansion in fish, type 'help expand-variable'.") |
| Error issued on invalid variable name. | |
| #define | COMPLETE_VAR_BRACKET_DESC _( L"Did you mean %ls{$%ls}%ls? The '$' character begins a variable name. A bracket, which directly followed a '$', is not allowed as a part of a variable name, and variable names may not be zero characters long. To learn more about variable expansion in fish, type 'help expand-variable'." ) |
| Error issued on invalid variable name. | |
| #define | COMPLETE_VAR_PARAN_DESC _( L"Did you mean (COMMAND)? In fish, the '$' character is only used for accessing variables. To learn more about command substitution in fish, type 'help expand-command-substitution'.") |
| Error issued on invalid variable name. | |
| #define | COMPLETE_CHILD_PROCESS_DESC _( L"Child process") |
| Description for child process. | |
| #define | COMPLETE_PROCESS_DESC _( L"Process") |
| Description for non-child process. | |
| #define | COMPLETE_JOB_DESC _( L"Job") |
| Description for long job. | |
| #define | COMPLETE_JOB_DESC_VAL _( L"Job: %ls") |
| Description for short job. | |
| #define | COMPLETE_SELF_DESC _( L"Shell process") |
| Description for the shells own pid. | |
| #define | COMPLETE_LAST_DESC _( L"Last background job") |
| Description for the shells own pid. | |
| #define | SELF_STR L"self" |
| String in process expansion denoting ourself. | |
| #define | LAST_STR L"last" |
| String in process expansion denoting last background job. | |
| #define | UNCLEAN_FIRST L"~%" |
| Characters which make a string unclean if they are the first character of the string. | |
| #define | UNCLEAN L"$*?\\\"'({})" |
| Unclean characters. | |
Functions | |
| int | expand_is_clean (const wchar_t *in) |
| Test if the specified argument is clean, i.e. | |
| static wchar_t * | expand_var (wchar_t *in) |
Return the environment variable value for the string starting at in. | |
| static int | is_quotable (wchar_t *str) |
| Test if the specified string does not contain character which can not be used inside a quoted string. | |
| wchar_t * | expand_escape_variable (const wchar_t *in) |
| Convert the variable value to a human readable form, i.e. | |
| static int | iswnumeric (const wchar_t *n) |
| Tests if all characters in the wide string are numeric. | |
| static int | match_pid (const wchar_t *cmd, const wchar_t *proc, int flags, int *offset) |
See if the process described by proc matches the commandline cmd. | |
| static int | find_process (const wchar_t *proc, int flags, array_list_t *out) |
Searches for a job with the specified job id, or a job or process which has the string proc as a prefix of its commandline. | |
| static int | expand_pid (wchar_t *in, int flags, array_list_t *out) |
| Process id expansion. | |
| void | expand_variable_error (const wchar_t *token, int token_pos, int error_pos) |
| Perform error reporting for a syntax error related to the variable expansion beginning at the specified character of the specified token. | |
| static int | parse_slice (wchar_t *in, wchar_t **end_ptr, array_list_t *idx) |
| static int | expand_variables (wchar_t *in, array_list_t *out, int last_idx) |
| Expand all environment variables in the string *ptr. | |
| static int | expand_brackets (wchar_t *in, int flags, array_list_t *out) |
| Perform bracket expansion. | |
| static int | expand_cmdsubst (wchar_t *in, array_list_t *out) |
| Perform cmdsubst expansion. | |
| static wchar_t * | expand_unescape (const wchar_t *in, int escape_special) |
| Wrapper around unescape funtion. | |
| static wchar_t * | expand_tilde_internal (wchar_t *in) |
| Attempts tilde expansion. | |
| wchar_t * | expand_tilde (wchar_t *in) |
| Perform tilde expansion and nothing else on the specified string. | |
| static void | remove_internal_separator (const void *s, int conv) |
| Remove any internal separators. | |
| int | expand_string (void *context, wchar_t *str, array_list_t *end_out, int flags) |
| Perform various forms of expansion on in, such as tilde expansion (. | |
| wchar_t * | expand_one (void *context, wchar_t *string, int flags) |
| expand_one is identical to expand_string, except it will fail if in expands to more than one string. | |
These functions perform several kinds of parameter expansion.
|
|
Description for short job. The job command is concatenated |
|
|
Unclean characters.
See |
|
|
Characters which make a string unclean if they are the first character of the string.
See |
|
|
Convert the variable value to a human readable form, i.e. escape things, handle arrays, etc. Suitable for pretty-printing.
|
|
|
Test if the specified argument is clean, i.e. it does not contain any tokens which need to be expanded or otherwise altered. Clean strings can be passed through expand_string and expand_one without changing them. About two thirds of all strings are clean, so skipping expansion on them actually does save a small amount of time, since it avoids multiple memory allocations during the expansion process.
|
|
||||||||||||||||
|
expand_one is identical to expand_string, except it will fail if in expands to more than one string. This is used for expanding command names.
If
|
|
||||||||||||||||||||
|
Perform various forms of expansion on in, such as tilde expansion (. expand_one is just a wrapper around this one. |
|
|
Perform tilde expansion and nothing else on the specified string. If tilde expansion is needed, the original string is freed and a new string, allocated using malloc, is returned.
|
|
|
Attempts tilde expansion. Of the string specified. If tilde expansion is performed, the original string is freed and a new string allocated using malloc is returned, otherwise, the original string is returned. |
|
||||||||||||
|
Wrapper around unescape funtion. Issues an error() on failiure. |
|
||||||||||||||||
|
Perform error reporting for a syntax error related to the variable expansion beginning at the specified character of the specified token. This function will call the error function with an explanatory string about what is wrong with the specified token.
|
|
||||||||||||||||
|
Expand all environment variables in the string *ptr. This function is slow, fragile and complicated. There are lots of little corner cases, like $$foo should do a double expansion, $foo$bar should not double expand bar, etc. Also, it's easy to accidentally leak memory on array out of bounds errors an various other situations. All in all, this function should be rewritten, split out into multiple logical units and carefully tested. After that, it can probably be optimized to do fewer memory allocations, fewer string scans and overall just less work. But until that happens, don't edit it unless you know exactly what you are doing, and do proper testing afterwards. |
|
||||||||||||||||
|
Searches for a job with the specified job id, or a job or process which has the string If the ACCEPT_INCOMPLETE flag is set, the remaining string for any matches are inserted.
Otherwise, any job matching the specified string is matched, and the job pgid is returned. If no job matches, all child processes are searched. If no child processes match, and |
|
||||||||||||
|
Remove any internal separators. Also optionally convert wildcard characters to regular equivalents. This is done to support EXPAND_SKIP_WILDCARDS. |
1.4.4