Skip to content

Instantly share code, notes, and snippets.

@cwgem
Created April 3, 2013 04:59
Show Gist options
  • Select an option

  • Save cwgem/5298556 to your computer and use it in GitHub Desktop.

Select an option

Save cwgem/5298556 to your computer and use it in GitHub Desktop.
Example of hardcoded iteration limit of positional parameters to single digit values in bash source code
/* Return the word list that corresponds to `$*'. */
WORD_LIST *
list_rest_of_args ()
{
register WORD_LIST *list, *args;
int i;
/* Break out of the loop as soon as one of the dollar variables is null. */
for (i = 1, list = (WORD_LIST *)NULL; i < 10 && dollar_vars[i]; i++)
list = make_word_list (make_bare_word (dollar_vars[i]), list);
for (args = rest_of_args; args; args = args->next)
list = make_word_list (make_bare_word (args->word->word), list);
return (REVERSE_LIST (list, WORD_LIST *));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment