概述
/* Non-zero means that this shell is a login shell.
Specifically:
0 = not login shell.
1 = login shell from getty (or equivalent fake out)
-1 = login shell from "-login" flag.
-2 = both from getty, and from flag.
*/
int login_shell = -2;
/* Non-zero means this shell is running interactively. */
int interactive = 0;
main (argc, argv, env)
int argc;
char **argv, **env;
{
......
/* All done with full word args; do standard shell arg parsing.*/
while (arg_index != argc && argv[arg_index] &&
(*(argv[arg_index]) == '-' || (*argv[arg_index] == '+')))
{
/* There are flag arguments, so parse them. */
int arg_character;
int on_or_off = (*argv[arg_index]);
int i = 1;
while (arg_character = (argv[arg_index])[i++])
{
switch (arg_character)
{
case 'c':
/* The next arg is a command to execute, and the following args
are $1 .. $n respectively. */
local_pending_command = argv[++arg_index];
if (!local_pending_command)
{
report_error ("`%cc' requires an argument", on_or_off);
exit (1);
}
arg_index++;
goto after_flags;
break;
default:
if (change_flag_char (arg_character, on_or_off) == FLAG_ERROR)
{
report_error ("%c%c: bad option", on_or_off, arg_character);
exit (1);
}
}
}
arg_index++;
}
after_flags:
/* First, let the outside world know about our interactive status. */
if (forced_interactive ||
(!local_pending_command &&
arg_index == argc &&
isatty (fileno (stdin)) &&
isatty (fileno (stdout))))
interactive = 1;
else
{
interactive = 0;
#ifdef JOB_CONTROL
job_control = 0;
#endif
}
最后
以上就是狂野诺言为你收集整理的bash源代码分析----login shell登录shell和interactive交互式shell的关系以及main函数中的change_flag_char函数的全部内容,希望文章能够帮你解决bash源代码分析----login shell登录shell和interactive交互式shell的关系以及main函数中的change_flag_char函数所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复