#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<string.h>
#include<errno.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#define MAX_STRING 256
#define SIGNIN "<"
#define SIGNOUT ">"
#define SIGNPINE "|"
const char* expst = "exit"; //控制终端输入exit,shell退出
int strToken(char* buf,char** p) //以空格符为标准分割字符串,字符串头指针存储在指针数组p中
{
int i = 0;
while((p[i] = strtok(buf, " ")) != NULL)
{
i++;
buf = NULL;
}
p[i-1] = NULL; //重点:在linux终端输入字符串是以‘\n’结束的,比如ls -l后回车,则三个字符串分别为ls\0,-l\0,\n\0
return (i-1); //p[i-1] = NULL 的目的就是消除字符串\n\0,为exeve的调用提供结尾参数NULL
}
int strProTok(char* buf, char** p)
{
int i