int parseline(const char *cmdline, char **argv)
{
static char array[MAXLINE]; /* holds local copy of command line */
char *buf = array; /* ptr that traverses command line */
char *delim; /* points to first space delimiter */
int argc; /* number of args */
int bg; /* background job? */
strcpy(buf, cmdline);
buf[strlen(buf)-1] = ' '; /* replace trailing '\n' with space */
while (*buf && (*buf == ' ')) /* ignore leading spaces */
buf++;
/* Build the argv list */
argc = 0;
if (*buf == '\'') {
buf++;
delim = strchr(buf, '\'');
}
else {
delim = strchr(buf, ' ');
}
//...
}
我不明白的部分是if (*buf == '\'')
。
我对这部分的了解是用定界符分割命令行,而后者是空格,那\'
意味着什么呢?
'\''
是转义的单引号
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句