⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smsh2.c

📁 unix和linux编程实践教程-源代码
💻 C
字号:
/** smsh2.c - small-shell version 2 **		small shell that supports command line parsing **		and if..then..else.fi logic (by calling process()) **/#include	<stdio.h>#include	<stdlib.h>#include	<unistd.h>#include	<signal.h>#include	<sys/wait.h>#include	"smsh.h"#define	DFL_PROMPT	"> "int main(){	char	*cmdline, *prompt, **arglist;	int	result, process(char **);	void	setup();	prompt = DFL_PROMPT ;	setup();	while ( (cmdline = next_cmd(prompt, stdin)) != NULL ){		if ( (arglist = splitline(cmdline)) != NULL  ){			result = process(arglist);			freelist(arglist);		}		free(cmdline);	}	return 0;}void setup()/* * purpose: initialize shell * returns: nothing. calls fatal() if trouble */{	signal(SIGINT,  SIG_IGN);	signal(SIGQUIT, SIG_IGN);}void fatal(char *s1, char *s2, int n){	fprintf(stderr,"Error: %s,%s\n", s1, s2);	exit(n);}

⌨️ 快捷键说明

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