testit.c

来自「支持X/YModem和cis_b+协议的串口通讯程序」· C语言 代码 · 共 53 行

C
53
字号
/*  $Revision: 1.2 $****  A "micro-shell" to test editline library.**  If given any arguments, commands aren't executed.*/#include <stdio.h>#include <stdlib.h>#ifdef MEMDEBUG#include <memdebug.h>#endif#ifndef TRUE#define TRUE 1#define FALSE 0#endif extern void rl_initialize( void );extern char *readline( char *, int );extern void *add_history( char * );char *luxptr = NULL ;int silent = 0 ;/* ARGSUSED1 */intmain(ac, av)    int		ac;    char	*av[];{    char	*p;    int		doit;    doit = ac == 1;	rl_initialize();    while ((p = readline("testit> ", TRUE )) != NULL) {	if( strncmp( p, "quit", 4) == 0 )	break; 		(void)printf("\t\t\t|%s|\n", p);	if (doit)	    if (strncmp(p, "cd ", 3) == 0) {		if (chdir(&p[3]) < 0)		    perror(&p[3]);	    }	    else if (system(p) != 0)		perror(p);	add_history(p);	free(p);	p = NULL ;    }    exit(0);    /* NOTREACHED */}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?