]> git.ipfire.org Git - thirdparty/bash.git/blame - subst.h
Imported from ../bash-2.03.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
19 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
20
21#if !defined (_SUBST_H_)
22#define _SUBST_H_
23
24#include "stdc.h"
25
26/* Cons a new string from STRING starting at START and ending at END,
27 not including END. */
28extern char *substring __P((char *, int, int));
29
30/* Remove backslashes which are quoting backquotes from STRING. Modifies
31 STRING, and returns a pointer to it. */
32extern char * de_backslash __P((char *));
33
34/* Replace instances of \! in a string with !. */
35extern void unquote_bang __P((char *));
36
37/* Extract the $( construct in STRING, and return a new string.
38 Start extracting at (SINDEX) as if we had just seen "$(".
39 Make (SINDEX) get the position just after the matching ")". */
40extern char *extract_command_subst __P((char *, int *));
41
42/* Extract the $[ construct in STRING, and return a new string.
43 Start extracting at (SINDEX) as if we had just seen "$[".
44 Make (SINDEX) get the position just after the matching "]". */
45extern char *extract_arithmetic_subst __P((char *, int *));
46
47#if defined (PROCESS_SUBSTITUTION)
48/* Extract the <( or >( construct in STRING, and return a new string.
49 Start extracting at (SINDEX) as if we had just seen "<(".
50 Make (SINDEX) get the position just after the matching ")". */
51extern char *extract_process_subst __P((char *, char *, int *));
52#endif /* PROCESS_SUBSTITUTION */
53
54/* Extract the name of the variable to bind to from the assignment string. */
55extern char *assignment_name __P((char *));
56
57/* Return a single string of all the words present in LIST, separating
58 each word with a space. */
59extern char *string_list __P((WORD_LIST *));
60
726f6388
JA
61/* Perform quoted null character removal on each element of LIST.
62 This modifies LIST. */
63extern void word_list_remove_quoted_nulls __P((WORD_LIST *));
64
65/* This performs word splitting and quoted null character removal on
66 STRING. */
67extern WORD_LIST *list_string __P((char *, char *, int));
68
69extern char *get_word_from_string __P((char **, char *, char **));
70extern char *strip_trailing_ifs_whitespace __P((char *, char *, int));
71
72/* Given STRING, an assignment string, get the value of the right side
73 of the `=', and bind it to the left side. If EXPAND is true, then
74 perform parameter expansion, command substitution, and arithmetic
75 expansion on the right-hand side. Perform tilde expansion in any
76 case. Do not perform word splitting on the result of expansion. */
77extern int do_assignment __P((char *));
78extern int do_assignment_no_expand __P((char *));
79
ccc6cda3
JA
80#if defined (ARRAY_VARS)
81extern SHELL_VAR *do_array_element_assignment __P((char *, char *));
82#endif
83
726f6388
JA
84/* Append SOURCE to TARGET at INDEX. SIZE is the current amount
85 of space allocated to TARGET. SOURCE can be NULL, in which
86 case nothing happens. Gets rid of SOURCE by free ()ing it.
87 Returns TARGET in case the location has changed. */
88extern char *sub_append_string __P((char *, char *, int *, int *));
89
90/* Append the textual representation of NUMBER to TARGET.
91 INDEX and SIZE are as in SUB_APPEND_STRING. */
92extern char *sub_append_number __P((int, char *, int *, int *));
93
94/* Return the word list that corresponds to `$*'. */
95extern WORD_LIST *list_rest_of_args __P((void));
96
97/* Make a single large string out of the dollar digit variables,
98 and the rest_of_args. If DOLLAR_STAR is 1, then obey the special
99 case of "$*" with respect to IFS. */
100extern char *string_rest_of_args __P((int));
101
ccc6cda3
JA
102extern int number_of_args __P((void));
103
726f6388
JA
104/* Expand STRING by performing parameter expansion, command substitution,
105 and arithmetic expansion. Dequote the resulting WORD_LIST before
106 returning it, but do not perform word splitting. The call to
107 remove_quoted_nulls () is in here because word splitting normally
108 takes care of quote removal. */
109extern WORD_LIST *expand_string_unsplit __P((char *, int));
110
111/* Expand STRING just as if you were expanding a word. This also returns
112 a list of words. Note that filename globbing is *NOT* done for word
113 or string expansion, just when the shell is expanding a command. This
114 does parameter expansion, command substitution, arithmetic expansion,
115 and word splitting. Dequote the resultant WORD_LIST before returning. */
116extern WORD_LIST *expand_string __P((char *, int));
117
118/* De-quoted quoted characters in STRING. */
119extern char *dequote_string __P((char *));
120
121/* Expand WORD, performing word splitting on the result. This does
122 parameter expansion, command substitution, arithmetic expansion,
123 word splitting, and quote removal. */
124extern WORD_LIST *expand_word __P((WORD_DESC *, int));
125
126/* Expand WORD, but do not perform word splitting on the result. This
127 does parameter expansion, command substitution, arithmetic expansion,
128 and quote removal. */
129extern WORD_LIST *expand_word_no_split __P((WORD_DESC *, int));
130extern WORD_LIST *expand_word_leave_quoted __P((WORD_DESC *, int));
131
132/* Return the value of a positional parameter. This handles values > 10. */
133extern char *get_dollar_var_value __P((int));
134
ccc6cda3
JA
135/* Quote a string to protect it from word splitting. */
136extern char *quote_string __P((char *));
137
726f6388
JA
138/* Perform quote removal on STRING. If QUOTED > 0, assume we are obeying the
139 backslash quoting rules for within double quotes. */
140extern char *string_quote_removal __P((char *, int));
141
142/* Perform quote removal on word WORD. This allocates and returns a new
143 WORD_DESC *. */
144extern WORD_DESC *word_quote_removal __P((WORD_DESC *, int));
145
146/* Perform quote removal on all words in LIST. If QUOTED is non-zero,
147 the members of the list are treated as if they are surrounded by
148 double quotes. Return a new list, or NULL if LIST is NULL. */
149extern WORD_LIST *word_list_quote_removal __P((WORD_LIST *, int));
150
151/* This splits a single word into a WORD LIST on $IFS, but only if the word
152 is not quoted. list_string () performs quote removal for us, even if we
153 don't do any splitting. */
154extern WORD_LIST *word_split __P((WORD_DESC *));
155
156/* Take the list of words in LIST and do the various substitutions. Return
157 a new list of words which is the expanded list, and without things like
158 variable assignments. */
159extern WORD_LIST *expand_words __P((WORD_LIST *));
160
161/* Same as expand_words (), but doesn't hack variable or environment
162 variables. */
163extern WORD_LIST *expand_words_no_vars __P((WORD_LIST *));
164
cce855bc
JA
165/* Perform the `normal shell expansions' on a WORD_LIST. These are
166 brace expansion, tilde expansion, parameter and variable substitution,
167 command substitution, arithmetic expansion, and word splitting. */
168extern WORD_LIST *expand_words_shellexp __P((WORD_LIST *));
726f6388 169
ccc6cda3
JA
170extern char *pat_subst __P((char *, char *, char *, int));
171
172extern void unlink_fifo_list __P((void));
173
174#if defined (ARRAY_VARS)
175extern int array_expand_index __P((char *, int));
176extern int valid_array_reference __P((char *));
177extern char *get_array_value __P((char *, int));
178extern SHELL_VAR *array_variable_part __P((char *, char **, int *));
179extern WORD_LIST *list_string_with_quotes __P((char *));
180extern char *extract_array_assignment_list __P((char *, int *));
181#endif
182
cce855bc
JA
183#if defined (COND_COMMAND)
184extern char *remove_backslashes __P((char *));
185extern char *cond_expand_word __P((WORD_DESC *, int));
ccc6cda3
JA
186#endif
187
ccc6cda3
JA
188/* How to determine the quoted state of the character C. */
189#define QUOTED_CHAR(c) ((c) == CTLESC)
190
191/* Is the first character of STRING a quoted NULL character? */
192#define QUOTED_NULL(string) ((string)[0] == CTLNUL && (string)[1] == '\0')
193
726f6388 194#endif /* !_SUBST_H_ */