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 {
107107
108108 #[ cfg( feature = "sudoedit" ) ]
109109 pub fn from_edit_opts ( sudo_options : SudoEditOptions ) -> Result < Context , Error > {
110+ use std:: path:: Path ;
110111 let hostname = Hostname :: resolve ( ) ;
111112 let current_user = CurrentUser :: resolve ( ) ?;
112113
@@ -115,9 +116,16 @@ impl Context {
115116
116117 // resolve file arguments; if something can't be resolved, don't add it to the "edit" list
117118 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) )
121129 } ) ;
122130
123131 let files_to_edit = resolved_args
You can’t perform that action at this time.
0 commit comments