redir_type type; /* type of redirection */
int fd; /* file descriptor being redirected */
int dup; /* -1, or file descriptor being duplicated */
- glob_t word; /* *word.gl_pathv is the filename */
+ glob_t glob_word; /* *word.gl_pathv is the filename */
};
struct child_prog {
char *data;
int length;
int maxlen;
- int quote;
- int nonnull;
+ smallint o_quote;
+ smallint nonnull;
} o_string;
#define NULL_O_STRING {NULL,0,0,0,0}
/* used for initialization: o_string foo = NULL_O_STRING; */
struct redir_struct *redir;
for (redir = prog->redirects; redir; redir = redir->next) {
- if (redir->dup == -1 && redir->word.gl_pathv == NULL) {
+ if (redir->dup == -1 && redir->glob_word.gl_pathv == NULL) {
/* something went wrong in the parse. Pretend it didn't happen */
continue;
}
if (redir->dup == -1) {
mode = redir_table[redir->type].mode;
- openfd = open_or_warn(redir->word.gl_pathv[0], mode);
+ openfd = open_or_warn(redir->glob_word.gl_pathv[0], mode);
if (openfd < 0) {
/* this could get lost if stderr has been redirected, but
bash and ash both lose it as well (though zsh doesn't!) */
debug_printf_clean("%s redirect %d%s", indenter(indent), r->fd, redir_table[r->type].descrip);
if (r->dup == -1) {
/* guard against the case >$FOO, where foo is unset or blank */
- if (r->word.gl_pathv) {
- debug_printf_clean(" %s\n", *r->word.gl_pathv);
- globfree(&r->word);
+ if (r->glob_word.gl_pathv) {
+ debug_printf_clean(" %s\n", r->glob_word.gl_pathv[0]);
+ globfree(&r->glob_word);
}
} else {
debug_printf_clean("&%d\n", r->dup);
return rcode;
}
+/* Whoever decided to muck with glob internal data is AN IDIOT! */
+/* uclibc happily changed the way it works (and it has rights to do so!),
+ all hell broke loose (SEGVs) */
+
/* The API for glob is arguably broken. This routine pushes a non-matching
* string into the output structure, removing non-backslashed backslashes.
* If someone can prove me wrong, by performing this function within the
last_redir = redir;
redir = redir->next;
}
- redir = xmalloc(sizeof(struct redir_struct));
- redir->next = NULL;
- redir->word.gl_pathv = NULL;
+ redir = xzalloc(sizeof(struct redir_struct));
+ /* redir->next = NULL; */
+ /* redir->glob_word.gl_pathv = NULL; */
if (last_redir) {
last_redir->next = redir;
} else {
return 0;
}
if (ctx->pending_redirect) {
- glob_target = &ctx->pending_redirect->word;
+ glob_target = &ctx->pending_redirect->glob_word;
} else {
if (child->group) {
syntax(NULL);
continue;
}
while (eol_cnt) {
- b_addqchr(dest, '\n', dest->quote);
+ b_addqchr(dest, '\n', dest->o_quote);
eol_cnt--;
}
- b_addqchr(dest, ch, dest->quote);
+ b_addqchr(dest, ch, dest->o_quote);
}
debug_printf("done reading from pipe, pclose()ing\n");
static int handle_dollar(o_string *dest, struct p_context *ctx, struct in_str *input)
{
int ch = b_peek(input); /* first character after the $ */
- unsigned char quote_mask = dest->quote ? 0x80 : 0;
+ unsigned char quote_mask = dest->o_quote ? 0x80 : 0;
debug_printf_parse("handle_dollar entered: ch='%c'\n", ch);
if (isalpha(ch)) {
return 1;
break;
default:
- b_addqchr(dest, '$', dest->quote);
+ b_addqchr(dest, '$', dest->o_quote);
}
debug_printf_parse("handle_dollar return 0\n");
return 0;
redir_type redir_style;
int next;
- /* Only double-quote state is handled in the state variable dest->quote.
+ /* Only double-quote state is handled in the state variable dest->o_quote.
* A single-quote triggers a bypass of the main loop until its mate is
- * found. When recursing, quote state is passed in via dest->quote. */
+ * found. When recursing, quote state is passed in via dest->o_quote. */
debug_printf_parse("parse_stream entered, end_trigger='%s'\n", end_trigger);
next = b_peek(input);
}
debug_printf_parse(": ch=%c (%d) m=%d quote=%d\n",
- ch, ch, m, dest->quote);
+ ch, ch, m, dest->o_quote);
if (m == CHAR_ORDINARY
- || (m != CHAR_SPECIAL && dest->quote)
+ || (m != CHAR_SPECIAL && dest->o_quote)
) {
if (ch == EOF) {
syntax("unterminated \"");
debug_printf_parse("parse_stream return 1: unterminated \"\n");
return 1;
}
- b_addqchr(dest, ch, dest->quote);
+ b_addqchr(dest, ch, dest->o_quote);
continue;
}
if (m == CHAR_IFS) {
}
}
if ((end_trigger && strchr(end_trigger, ch))
- && !dest->quote && ctx->res_w == RES_NONE
+ && !dest->o_quote && ctx->res_w == RES_NONE
) {
debug_printf_parse("parse_stream return 0: end_trigger char found\n");
return 0;
continue;
switch (ch) {
case '#':
- if (dest->length == 0 && !dest->quote) {
+ if (dest->length == 0 && !dest->o_quote) {
while (1) {
ch = b_peek(input);
if (ch == EOF || ch == '\n')
b_getch(input);
}
} else {
- b_addqchr(dest, ch, dest->quote);
+ b_addqchr(dest, ch, dest->o_quote);
}
break;
case '\\':
debug_printf_parse("parse_stream return 1: \\<eof>\n");
return 1;
}
- b_addqchr(dest, '\\', dest->quote);
- b_addqchr(dest, b_getch(input), dest->quote);
+ b_addqchr(dest, '\\', dest->o_quote);
+ b_addqchr(dest, b_getch(input), dest->o_quote);
break;
case '$':
if (handle_dollar(dest, ctx, input) != 0) {
break;
case '"':
dest->nonnull = 1;
- dest->quote = !dest->quote;
+ dest->o_quote ^= 1; /* invert */
break;
#if ENABLE_HUSH_TICK
case '`':
b_reset(&temp);
}
temp.nonnull = 0;
- temp.quote = 0;
+ temp.o_quote = 0;
inp->p = NULL;
free_pipe_list(ctx.list_head, 0);
}