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 13
13
14
14
#![ recursion_limit = "1024" ]
15
15
16
- use std:: path:: PathBuf ;
17
-
18
16
use anyhow:: { anyhow, Result } ;
19
17
use cfg_if:: cfg_if;
20
18
use rs_tracing:: * ;
@@ -62,18 +60,7 @@ fn run_rustup_inner() -> Result<utils::ExitCode> {
62
60
utils:: current_dir ( ) ?;
63
61
utils:: current_exe ( ) ?;
64
62
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 ( ) {
77
64
Some ( "rustup" ) => rustup_mode:: main ( ) ,
78
65
Some ( n) if n. starts_with ( "rustup-setup" ) || n. starts_with ( "rustup-init" ) => {
79
66
// 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:
87
87
+ Debug
88
88
{
89
89
fn clone_boxed ( & self ) -> Box < dyn CurrentProcess > ;
90
+
91
+ fn name ( & self ) -> Option < String > ;
90
92
}
91
93
92
94
// Machinery for Cloning boxes
@@ -107,6 +109,19 @@ where
107
109
fn clone_boxed ( & self ) -> Box < dyn CurrentProcess + ' static > {
108
110
Box :: new ( T :: clone ( self ) )
109
111
}
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
+ }
110
125
}
111
126
112
127
impl Clone for Box < dyn CurrentProcess + ' static > {
You can’t perform that action at this time.
0 commit comments