- /* Parameters which start with quotes or pipes are treated
- * specially. Bare parameters are delimited by whitespace.
- */
- if (*p == '"') {
- p++;
- len = strcspn (p, "\"");
- if (p[len] == '\0') {
- fprintf (stderr, _("%s: unterminated double quote\n"), program_name);
- if (exit_on_error) exit (EXIT_FAILURE);
- goto next_command;
- }
- if (p[len+1] && (p[len+1] != ' ' && p[len+1] != '\t')) {
- fprintf (stderr,
- _("%s: command arguments not separated by whitespace\n"),
- program_name);
- if (exit_on_error) exit (EXIT_FAILURE);
- goto next_command;
- }
- p[len] = '\0';
- pend = p[len+1] ? &p[len+2] : &p[len+1];
- } else if (*p == '\'') {
- p++;
- len = strcspn (p, "'");
- if (p[len] == '\0') {
- fprintf (stderr, _("%s: unterminated single quote\n"), program_name);
- if (exit_on_error) exit (EXIT_FAILURE);
- goto next_command;
- }
- if (p[len+1] && (p[len+1] != ' ' && p[len+1] != '\t')) {
- fprintf (stderr,
- _("%s: command arguments not separated by whitespace\n"),
- program_name);
- if (exit_on_error) exit (EXIT_FAILURE);
- goto next_command;
- }
- p[len] = '\0';
- pend = p[len+1] ? &p[len+2] : &p[len+1];
- } else if (*p == '|') {
- *p = '\0';
- pipe = p+1;
- continue;
- /*
- } else if (*p == '[') {
- int c = 1;
- p++;
- pend = p;
- while (*pend && c != 0) {
- if (*pend == '[') c++;
- else if (*pend == ']') c--;
- pend++;
- }
- if (c != 0) {
- fprintf (stderr,
- _("%s: unterminated \"[...]\" sequence\n"), program_name);
- if (exit_on_error) exit (EXIT_FAILURE);
- goto next_command;
- }
- if (*pend && (*pend != ' ' && *pend != '\t')) {
- fprintf (stderr,
- _("%s: command arguments not separated by whitespace\n"),
- program_name);
- if (exit_on_error) exit (EXIT_FAILURE);
- goto next_command;
- }
- *(pend-1) = '\0';
- */
- } else if (*p != ' ' && *p != '\t') {
- /* If the first character is a ~ then note that this parameter
- * is a candidate for ~username expansion. NB this does not
- * apply to quoted parameters.
- */
- tilde_candidate = *p == '~';
- len = strcspn (p, " \t");
- if (p[len]) {
- p[len] = '\0';
- pend = &p[len+1];
- } else
- pend = &p[len];
- } else {
- fprintf (stderr, _("%s: internal error parsing string at '%s'\n"),
- program_name, p);
- abort ();
- }