File tree Expand file tree Collapse file tree 2 files changed +16
-14
lines changed Expand file tree Collapse file tree 2 files changed +16
-14
lines changed Original file line number Diff line number Diff line change 1313
1414#![ recursion_limit = "1024" ]
1515
16- use std:: path:: PathBuf ;
17-
1816use anyhow:: { anyhow, Result } ;
1917use cfg_if:: cfg_if;
2018use rs_tracing:: * ;
@@ -62,18 +60,7 @@ fn run_rustup_inner() -> Result<utils::ExitCode> {
6260 utils:: current_dir ( ) ?;
6361 utils:: current_exe ( ) ?;
6462
65- // The name of arg0 determines how the program is going to behave
66- let arg0 = match process ( ) . var ( "RUSTUP_FORCE_ARG0" ) {
67- Ok ( v) => Some ( v) ,
68- Err ( _) => process ( ) . args ( ) . next ( ) ,
69- }
70- . map ( PathBuf :: from) ;
71- let name = arg0
72- . as_ref ( )
73- . and_then ( |a| a. file_stem ( ) )
74- . and_then ( std:: ffi:: OsStr :: to_str) ;
75-
76- match name {
63+ match process ( ) . name ( ) . as_deref ( ) {
7764 Some ( "rustup" ) => rustup_mode:: main ( ) ,
7865 Some ( n) if n. starts_with ( "rustup-setup" ) || n. starts_with ( "rustup-init" ) => {
7966 // NB: The above check is only for the prefix of the file
Original file line number Diff line number Diff line change @@ -87,6 +87,8 @@ pub trait CurrentProcess:
8787 + Debug
8888{
8989 fn clone_boxed ( & self ) -> Box < dyn CurrentProcess > ;
90+
91+ fn name ( & self ) -> Option < String > ;
9092}
9193
9294// Machinery for Cloning boxes
@@ -107,6 +109,19 @@ where
107109 fn clone_boxed ( & self ) -> Box < dyn CurrentProcess + ' static > {
108110 Box :: new ( T :: clone ( self ) )
109111 }
112+
113+ fn name ( & self ) -> Option < String > {
114+ let arg0 = match self . var ( "RUSTUP_FORCE_ARG0" ) {
115+ Ok ( v) => Some ( v) ,
116+ Err ( _) => self . args ( ) . next ( ) ,
117+ }
118+ . map ( PathBuf :: from) ;
119+
120+ arg0. as_ref ( )
121+ . and_then ( |a| a. file_stem ( ) )
122+ . and_then ( std:: ffi:: OsStr :: to_str)
123+ . map ( String :: from)
124+ }
110125}
111126
112127impl Clone for Box < dyn CurrentProcess + ' static > {
You can’t perform that action at this time.
0 commit comments