Ejemplo n.º 1
0
int builtin_command(char **args)
{
  int rv = 0;
  int exit_val;

  if (strcmp(args[0], "set") == 0)
  {
    VLlist();
    rv = 1;
  }
  else if (strchr(args[0], '=') != NULL)
  {
    rv = assign(args[0]);
  }
  else if (strcmp(args[0], "export") == 0)
  {
    if ((args[1] != NULL) && okname(args[1]))
      VLexport(args[1]);

    rv = 1;
  }
  else if (strcmp(args[0], "exit") == 0)
  {
    exit_val = 0;
    if (args[1] == NULL || is_numeric(args[1]))
    {
      if (args[1] != NULL)
        exit_val = atoi(args[1]);

      exit(exit_val);
    }
  }

  return rv;
}
Ejemplo n.º 2
0
int builtin_command(char ** args,int *resultp)
{
    int rv = 0;
    if(strcmp(args[0],"set")==0)
    {
        VLlist();
        *resultp;
        rv = 1;
    }
    else if (strchr(args[0],'=')!=NULL)
    {
        *resultp = assign(args[0]);
        if(*resultp != -1)
        rv = 1;
    }
    else if (strcmp(args[0],"export") == 0)
    {
        if(args[1] != NULL && okname(args[1]))
        {
            *resultp = VLexport(args[1]);
        }
        else
        *resultp = 1;
        rv =1;
    }
    return rv;
}
Ejemplo n.º 3
0
int builtin_command(char **args, int *resultp)
/*
 * purpose: run a builtin command 
 * returns: 1 if args[0] is builtin, 0 if not
 * details: test args[0] against all known builtins.  Call functions
 */
{
	int rv = 0;

	if ( strcmp(args[0],"set") == 0 ){	     /* 'set' command? */
		VLlist();
		*resultp = 0;
		rv = 1;
	}
	else if ( strchr(args[0], '=') != NULL ){   /* assignment cmd */
		*resultp = assign(args[0]);
		if ( *resultp != -1 )		    /* x-y=123 not ok */
			rv = 1;
	}
	else if ( strcmp(args[0], "export") == 0 ){
		if ( args[1] != NULL && okname(args[1]) )
			*resultp = VLexport(args[1]);
		else
			*resultp = 1;
		rv = 1;
	}
	return rv;
}
Ejemplo n.º 4
0
/* 
 * ===  FUNCTION  ======================================================================
 *         Name:  builtin_command
 *  Description:  1 for build in command, 0 for not 
 * =====================================================================================
 */
   int 
builtin_command (char **args, int * resultp)
{
    int rv = 0;
    if (strcmp(args[0],"set") == 0)
    {
	VLlist();
	*resultp = 0;
	rv = 1;
    }else if (strchr(args[0],'=') != NULL)
    {
	*resultp = assign(args[0]);
	if (*resultp != -1)
	    rv =1;
    }else if (strcmp(args[0],"export") == 0)
    {
	if (args[1]!=NULL&&okname(args[1]))
	    *resultp = VLexport(args[1]);
	else
	    *resultp = 1;
	rv = 1;
    }else if (strcmp(args[0],"cd") == 0)
    {
	if (args[1]!= NULL )
	{
	    *resultp = VLstore("PWD",args[1]);
	    rv = 1;
	}
    }else if (strcmp(args[0],"exit") == 0)
    {
	rv = 1;
    }
    else if (findCharFromArgv("&",args) == 0)
    {
                                                /* implement '&' char processing, which put the porcess running in back groud */

    }                                           

    return rv;
}		/* -----  end of function builtin_command  ----- */