コード例 #1
0
ファイル: alias_test.c プロジェクト: cameronbroe/rosh
int main (int argc, char const *argv[]) {
  /* code */
  char** test = (char**) malloc(128 * sizeof(char*));
  test[0] = "ls";
  test[1] = "-lh";
  define_alias("test", test);
  alias_t testAlias = (alias_t) get_alias("test");
  //printf("%s\n", testAlias.cmd[1]);
  list_aliases();
  /*
  char* alias_key = (char*) get_alias_key(0);
  char** alias_cmd = (char**) get_alias_cmd(0);
  printf("%s\n", alias_cmd[1]);
  printf("%s\n", alias_key);
  shell_exec(alias_cmd[0], alias_cmd);
  */
  //shell_exec(testAlias.cmd[0], testAlias.cmd);
  return 0;
}
コード例 #2
0
ファイル: git.c プロジェクト: benpeart/git
static int list_cmds(const char *spec)
{
	struct string_list list = STRING_LIST_INIT_DUP;
	int i;

	while (*spec) {
		const char *sep = strchrnul(spec, ',');
		int len = sep - spec;

		if (match_token(spec, len, "builtins"))
			list_builtins(&list, 0);
		else if (match_token(spec, len, "main"))
			list_all_main_cmds(&list);
		else if (match_token(spec, len, "others"))
			list_all_other_cmds(&list);
		else if (match_token(spec, len, "nohelpers"))
			exclude_helpers_from_list(&list);
		else if (match_token(spec, len, "alias"))
			list_aliases(&list);
		else if (match_token(spec, len, "config"))
			list_cmds_by_config(&list);
		else if (len > 5 && !strncmp(spec, "list-", 5)) {
			struct strbuf sb = STRBUF_INIT;

			strbuf_add(&sb, spec + 5, len - 5);
			list_cmds_by_category(&list, sb.buf);
			strbuf_release(&sb);
		}
		else
			die(_("unsupported command listing type '%s'"), spec);
		spec += len;
		if (*spec == ',')
			spec++;
	}
	for (i = 0; i < list.nr; i++)
		puts(list.items[i].string);
	string_list_clear(&list, 0);
	return 0;
}