File tree Expand file tree Collapse file tree 1 file changed +2
-30
lines changed Expand file tree Collapse file tree 1 file changed +2
-30
lines changed Original file line number Diff line number Diff line change @@ -123,41 +123,13 @@ pub fn resolve_executable(exec: &Path) -> Result<PathBuf> {
123123 } ) ;
124124 for candidate in candidates {
125125 if candidate. is_file ( ) {
126- // PATH may have a component like "." in it, so we still need to
127- // canonicalize.
128- // Only do so if there are relative path components
129- let has_relative_path_components = candidate. components ( ) . any ( |c| {
130- matches ! (
131- c,
132- std:: path:: Component :: ParentDir | std:: path:: Component :: CurDir
133- )
134- } ) ;
135- return Ok ( if has_relative_path_components {
136- // Assure symlinks to programs like 'echo' don't change the file-name after resolution.
137- // root program like 'coreutils' which relies on the executable name for proper function.
138- let file_name = candidate
139- . file_name ( )
140- . expect ( "executables have a file name" )
141- . to_owned ( ) ;
142- let candidate = candidate
143- . canonicalize ( ) ?
144- . parent ( )
145- . expect ( "a parent is always available for tools called in test-suite" )
146- . join ( file_name)
147- . to_owned ( ) ;
148- if !candidate. is_file ( ) {
149- continue ;
150- }
151- candidate
152- } else {
153- candidate
154- } ) ;
126+ return Ok ( candidate) ;
155127 }
156128 }
157129
158130 anyhow:: bail!( "no executable for `{}` found in PATH" , exec. display( ) )
159131 } else {
160- Ok ( exec. canonicalize ( ) ? )
132+ Ok ( exec. into ( ) )
161133 }
162134}
163135
You can’t perform that action at this time.
0 commit comments