]> git.ipfire.org Git - thirdparty/bash.git/blame - subst.h
Imported from ../bash-2.05.tar.gz.
[thirdparty/bash.git] / subst.h
CommitLineData
726f6388
JA
1/* subst.h -- Names of externally visible functions in subst.c. */
2
3/* Copyright (C) 1993 Free Software Foundation, Inc.
4
5 This file is part of GNU Bash, the Bourne Again SHell.
6
7 Bash is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
11
12 Bash is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License along
18 with Bash; see the file COPYING. If not, write to the Free Software
bb70624e 19 Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
726f6388
JA
20
21#if !defined (_SUBST_H_)
22#define _SUBST_H_
23
24#include "stdc.h"
25
28ef6c31
JA
26/* Constants which specify how to handle backslashes and quoting in
27 expand_word_internal (). Q_DOUBLE_QUOTES means to use the function
28 slashify_in_quotes () to decide whether the backslash should be
29 retained. Q_HERE_DOCUMENT means slashify_in_here_document () to
30 decide whether to retain the backslash. Q_KEEP_BACKSLASH means
31 to unconditionally retain the backslash. */
32#define Q_DOUBLE_QUOTES 0x1
33#define Q_HERE_DOCUMENT 0x2
34#define Q_KEEP_BACKSLASH 0x4
35#define Q_NOQUOTE 0x8
36#define Q_QUOTED 0x10
37#define Q_ADDEDQUOTES 0x20
38#define Q_QUOTEDNULL 0x40
39
726f6388
JA
40/* Cons a new string from STRING starting at START and ending at END,
41 not including END. */
42extern char *substring __P((char *, int, int));
43
44/* Remove backslashes which are quoting backquotes from STRING. Modifies
45 STRING, and returns a pointer to it. */
46extern char * de_backslash __P((char *));
47
48/* Replace instances of \! in a string with !. */
49extern void unquote_bang __P((char *));
50
51/* Extract the $( construct in STRING, and return a new string.
52 Start extracting at (SINDEX) as if we had just seen "$(".
53 Make (SINDEX) get the position just after the matching ")". */
54extern char *extract_command_subst __P((char *, int *));
55
56/* Extract the $[ construct in STRING, and return a new string.
57 Start extracting at (SINDEX) as if we had just seen "$[".
58 Make (SINDEX) get the position just after the matching "]". */
59extern char *extract_arithmetic_subst __P((char *, int *));
60
61#if defined (PROCESS_SUBSTITUTION)
62/* Extract the <( or >( construct in STRING, and return a new string.
63 Start extracting at (SINDEX) as if we had just seen "<(".
64 Make (SINDEX) get the position just after the matching ")". */
65extern char *extract_process_subst __P((char *, char *, int *));
66#endif /* PROCESS_SUBSTITUTION */
67
68/* Extract the name of the variable to bind to from the assignment string. */
69extern char *assignment_name __P((char *));
70
71/* Return a single string of all the words present in LIST, separating
72 each word with a space. */
73extern char *string_list __P((WORD_LIST *));
74
726f6388
JA
75/* Perform quoted null character removal on each element of LIST.
76 This modifies LIST. */
77extern void word_list_remove_quoted_nulls __P((WORD_LIST *));
78
79/* This performs word splitting and quoted null character removal on
80 STRING. */
81extern WORD_LIST *list_string __P((char *, char *, int));
82
83extern char *get_word_from_string __P((char **, char *, char **));
84extern char *strip_trailing_ifs_whitespace __P((char *, char *, int));
85
86/* Given STRING, an assignment string, get the value of the right side
87 of the `=', and bind it to the left side. If EXPAND is true, then
88 perform parameter expansion, command substitution, and arithmetic
89 expansion on the right-hand side. Perform tilde expansion in any
90 case. Do not perform word splitting on the result of expansion. */
91extern int do_assignment __P((char *));
92extern int do_assignment_no_expand __P((char *));
93
ccc6cda3
JA
94#if defined (ARRAY_VARS)
95extern SHELL_VAR *do_array_element_assignment __P((char *, char *));
96#endif
97
726f6388
JA
98/* Append SOURCE to TARGET at INDEX. SIZE is the current amount
99 of space allocated to TARGET. SOURCE can be NULL, in which
100 case nothing happens. Gets rid of SOURCE by free ()ing it.
101 Returns TARGET in case the location has changed. */
102extern char *sub_append_string __P((char *, char *, int *, int *));
103
104/* Append the textual representation of NUMBER to TARGET.
105 INDEX and SIZE are as in SUB_APPEND_STRING. */
106extern char *sub_append_number __P((int, char *, int *, int *));
107
108/* Return the word list that corresponds to `$*'. */
109extern WORD_LIST *list_rest_of_args __P((void));
110
111/* Make a single large string out of the dollar digit variables,
112 and the rest_of_args. If DOLLAR_STAR is 1, then obey the special
113 case of "$*" with respect to IFS. */
114extern char *string_rest_of_args __P((int));
115
ccc6cda3
JA
116extern int number_of_args __P((void));
117
726f6388
JA
118/* Expand STRING by performing parameter expansion, command substitution,
119 and arithmetic expansion. Dequote the resulting WORD_LIST before
120 returning it, but do not perform word splitting. The call to
121 remove_quoted_nulls () is in here because word splitting normally
122 takes care of quote removal. */
123extern WORD_LIST *expand_string_unsplit __P((char *, int));
124
bb70624e
JA
125/* Expand a prompt string. */
126extern WORD_LIST *expand_prompt_string __P((char *, int));
127
726f6388
JA
128/* Expand STRING just as if you were expanding a word. This also returns
129 a list of words. Note that filename globbing is *NOT* done for word
130 or string expansion, just when the shell is expanding a command. This
131 does parameter expansion, command substitution, arithmetic expansion,
132 and word splitting. Dequote the resultant WORD_LIST before returning. */
133extern WORD_LIST *expand_string __P((char *, int));
134
135/* De-quoted quoted characters in STRING. */
136extern char *dequote_string __P((char *));
137
138/* Expand WORD, performing word splitting on the result. This does
139 parameter expansion, command substitution, arithmetic expansion,
140 word splitting, and quote removal. */
141extern WORD_LIST *expand_word __P((WORD_DESC *, int));
142
143/* Expand WORD, but do not perform word splitting on the result. This
144 does parameter expansion, command substitution, arithmetic expansion,
145 and quote removal. */
28ef6c31 146extern WORD_LIST *expand_word_unsplit __P((WORD_DESC *, int));
726f6388
JA
147extern WORD_LIST *expand_word_leave_quoted __P((WORD_DESC *, int));
148
149/* Return the value of a positional parameter. This handles values > 10. */
150extern char *get_dollar_var_value __P((int));
151
ccc6cda3
JA
152/* Quote a string to protect it from word splitting. */
153extern char *quote_string __P((char *));
154
726f6388
JA
155/* Perform quote removal on STRING. If QUOTED > 0, assume we are obeying the
156 backslash quoting rules for within double quotes. */
157extern char *string_quote_removal __P((char *, int));
158
159/* Perform quote removal on word WORD. This allocates and returns a new
160 WORD_DESC *. */
161extern WORD_DESC *word_quote_removal __P((WORD_DESC *, int));
162
163/* Perform quote removal on all words in LIST. If QUOTED is non-zero,
164 the members of the list are treated as if they are surrounded by
165 double quotes. Return a new list, or NULL if LIST is NULL. */
166extern WORD_LIST *word_list_quote_removal __P((WORD_LIST *, int));
167
168/* This splits a single word into a WORD LIST on $IFS, but only if the word
169 is not quoted. list_string () performs quote removal for us, even if we
170 don't do any splitting. */
171extern WORD_LIST *word_split __P((WORD_DESC *));
172
173/* Take the list of words in LIST and do the various substitutions. Return
174 a new list of words which is the expanded list, and without things like
175 variable assignments. */
176extern WORD_LIST *expand_words __P((WORD_LIST *));
177
178/* Same as expand_words (), but doesn't hack variable or environment
179 variables. */
180extern WORD_LIST *expand_words_no_vars __P((WORD_LIST *));
181
cce855bc
JA
182/* Perform the `normal shell expansions' on a WORD_LIST. These are
183 brace expansion, tilde expansion, parameter and variable substitution,
184 command substitution, arithmetic expansion, and word splitting. */
185extern WORD_LIST *expand_words_shellexp __P((WORD_LIST *));
726f6388 186
bb70624e 187extern char *command_substitute __P((char *, int));
ccc6cda3
JA
188extern char *pat_subst __P((char *, char *, char *, int));
189
190extern void unlink_fifo_list __P((void));
191
bb70624e
JA
192extern WORD_LIST *list_string_with_quotes __P((char *));
193
ccc6cda3
JA
194#if defined (ARRAY_VARS)
195extern int array_expand_index __P((char *, int));
196extern int valid_array_reference __P((char *));
197extern char *get_array_value __P((char *, int));
198extern SHELL_VAR *array_variable_part __P((char *, char **, int *));
ccc6cda3
JA
199extern char *extract_array_assignment_list __P((char *, int *));
200#endif
201
cce855bc
JA
202#if defined (COND_COMMAND)
203extern char *remove_backslashes __P((char *));
204extern char *cond_expand_word __P((WORD_DESC *, int));
ccc6cda3
JA
205#endif
206
bb70624e
JA
207#if defined (READLINE)
208extern int char_is_quoted __P((char *, int));
209extern int unclosed_pair __P((char *, int, char *));
210extern int skip_to_delim __P((char *, int, char *));
211extern WORD_LIST *split_at_delims __P((char *, int, char *, int, int *, int *));
212#endif
213
ccc6cda3
JA
214/* How to determine the quoted state of the character C. */
215#define QUOTED_CHAR(c) ((c) == CTLESC)
216
217/* Is the first character of STRING a quoted NULL character? */
218#define QUOTED_NULL(string) ((string)[0] == CTLNUL && (string)[1] == '\0')
219
726f6388 220#endif /* !_SUBST_H_ */