File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,7 @@ impl Context {
107
107
108
108
#[ cfg( feature = "sudoedit" ) ]
109
109
pub fn from_edit_opts ( sudo_options : SudoEditOptions ) -> Result < Context , Error > {
110
+ use std:: path:: Path ;
110
111
let hostname = Hostname :: resolve ( ) ;
111
112
let current_user = CurrentUser :: resolve ( ) ?;
112
113
@@ -115,9 +116,16 @@ impl Context {
115
116
116
117
// resolve file arguments; if something can't be resolved, don't add it to the "edit" list
117
118
let resolved_args = sudo_options. positional_args . iter ( ) . map ( |arg| {
118
- crate :: common:: resolve:: canonicalize_newfile ( arg)
119
- . map_err ( |_| arg)
120
- . and_then ( |path| path. into_os_string ( ) . into_string ( ) . map_err ( |_| arg) )
119
+ let path = Path :: new ( arg) ;
120
+ let absolute_path;
121
+ crate :: common:: resolve:: canonicalize_newfile ( if path. is_absolute ( ) {
122
+ path
123
+ } else {
124
+ absolute_path = Path :: new ( "." ) . join ( path) ;
125
+ & absolute_path
126
+ } )
127
+ . map_err ( |_| arg)
128
+ . and_then ( |path| path. into_os_string ( ) . into_string ( ) . map_err ( |_| arg) )
121
129
} ) ;
122
130
123
131
let files_to_edit = resolved_args
You can’t perform that action at this time.
0 commit comments