From c3a1473419ea8157048321205684985a7ec5177b Mon Sep 17 00:00:00 2001 From: axel Date: Fri, 3 Feb 2006 10:37:54 +1000 Subject: [PATCH] Add fish switch to enter login mode darcs-hash:20060203003754-ac50b-99961eb6635beb0700fbd542fc7ff979ab1ceeb9.gz --- init/completions/fish.fish | 1 + main.c | 27 ++++++++++++++------------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/init/completions/fish.fish b/init/completions/fish.fish index 1ade805f6..b49f98a12 100644 --- a/init/completions/fish.fish +++ b/init/completions/fish.fish @@ -2,4 +2,5 @@ complete -c fish -s c -l "command" -d (_ "Run fish with this command") complete -c fish -s h -l help -d (_ "Display help and exit") complete -c fish -s v -l version -d (_ "Display version and exit") complete -c fish -s i -l interactive -d (_ "Run in interactive mode") +complete -c fish -s l -l login -d (_ "Run in login mode") complete -c fish -s p -l profile -d (_ "Output profiling information to specified file") -f diff --git a/main.c b/main.c index 2dbb97266..079f59642 100644 --- a/main.c +++ b/main.c @@ -124,6 +124,10 @@ int main( int argc, char **argv ) "interactive", no_argument, 0, 'i' } , + { + "login", no_argument, 0, 'l' + } + , { "profile", required_argument, 0, 'p' } @@ -146,14 +150,14 @@ int main( int argc, char **argv ) int opt = getopt_long( argc, argv, - "hivc:p:", + "hilvc:p:", long_options, &opt_index ); #else int opt = getopt( argc, argv, - "hivc:p:" ); + "hilvc:p:" ); #endif if( opt == -1 ) break; @@ -170,14 +174,16 @@ int main( int argc, char **argv ) case 'h': cmd = "help"; - //interactive=0; - break; case 'i': force_interactive = 1; break; + case 'l': + is_login=1; + break; + case 'p': profile = optarg; break; @@ -198,16 +204,11 @@ int main( int argc, char **argv ) my_optind = optind; is_login |= strcmp( argv[0], "-fish") == 0; -// fwprintf( stderr, L"%s\n", argv[0] ); is_interactive_session &= (cmd == 0); is_interactive_session &= (my_optind == argc); is_interactive_session &= isatty(STDIN_FILENO); - -// fwprintf( stderr, L"%d %d %d\n", cmd==0, my_optind == argc, isatty(STDIN_FILENO) ); - - if( force_interactive ) - is_interactive_session=1; + is_interactive_session |= force_interactive; translate_init(); proc_init(); @@ -274,7 +275,7 @@ int main( int argc, char **argv ) reader_push_current_filename( intern( abs_filename ) ); free( rel_filename ); free( abs_filename ); - + res = reader_read( fd ); if( res ) @@ -289,7 +290,7 @@ int main( int argc, char **argv ) } proc_fire_event( L"PROCESS_EXIT", EVENT_EXIT, getpid(), res ); - + proc_destroy(); env_destroy(); builtin_destroy(); @@ -303,7 +304,7 @@ int main( int argc, char **argv ) event_destroy(); output_destroy(); translate_destroy(); - + intern_free_all(); return res;