@@ -11,8 +11,7 @@ use crate::system::{time::Duration, timestamp::SessionRecordFile, Process};
11
11
pub ( crate ) use cli:: SudoAction ;
12
12
#[ cfg( not( test) ) ]
13
13
use cli:: SudoAction ;
14
- use std:: os:: unix:: ffi:: OsStrExt ;
15
- use std:: path:: { Path , PathBuf } ;
14
+ use std:: path:: PathBuf ;
16
15
17
16
mod cli;
18
17
pub ( crate ) use cli:: { SudoEditOptions , SudoListOptions , SudoRunOptions , SudoValidateOptions } ;
@@ -112,47 +111,12 @@ fn sudo_process() -> Result<(), Error> {
112
111
if options. positional_args . is_empty ( ) && !options. shell && !options. login {
113
112
eprintln_ignore_io_error ! ( "{}" , usage_msg) ;
114
113
std:: process:: exit ( 1 ) ;
115
- }
114
+ } else {
115
+ #[ cfg( feature = "dev" ) ]
116
+ unstable_warning ( ) ;
116
117
117
- if let Some ( cmd) = options. positional_args . first ( ) {
118
- let cmd = Path :: new ( cmd) ;
119
- // This checks if the last character in the path is a /. This
120
- // works because the OS directly splits at b'/' without regards
121
- // for if it is part of another character (which it can't be
122
- // with UTF-8 anyways).
123
- let is_dir = cmd. as_os_str ( ) . as_bytes ( ) . ends_with ( b"/" ) ;
124
- if !is_dir && ( cmd. ends_with ( "sudoedit" ) || cmd. ends_with ( "sudoedit-rs" ) ) {
125
- eprintln_ignore_io_error ! ( "sudoedit doesn't need to be run via sudo" ) ;
126
- #[ cfg( feature = "sudoedit" ) ]
127
- return pipeline:: run_edit ( SudoEditOptions {
128
- bell : options. bell ,
129
- reset_timestamp : options. reset_timestamp ,
130
- non_interactive : options. non_interactive ,
131
- stdin : options. stdin ,
132
- prompt : options. prompt ,
133
- chdir : options. chdir ,
134
- group : options. group ,
135
- user : options. user ,
136
- positional_args : {
137
- let mut args = options. positional_args ;
138
- args. remove ( 0 ) ; // Remove the sudoedit command
139
- args
140
- } ,
141
- } ) ;
142
- #[ cfg( not( feature = "sudoedit" ) ) ]
143
- {
144
- eprintln_ignore_io_error ! (
145
- "error: `--edit` flag has not yet been implemented"
146
- ) ;
147
- std:: process:: exit ( 1 ) ;
148
- }
149
- }
118
+ pipeline:: run ( options)
150
119
}
151
-
152
- #[ cfg( feature = "dev" ) ]
153
- unstable_warning ( ) ;
154
-
155
- pipeline:: run ( options)
156
120
}
157
121
SudoAction :: List ( options) => pipeline:: run_list ( options) ,
158
122
#[ cfg( feature = "sudoedit" ) ]
0 commit comments