File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -125,16 +125,30 @@ pub fn resolve_executable(exec: &Path) -> Result<PathBuf> {
125125 if candidate. is_file ( ) {
126126 // PATH may have a component like "." in it, so we still need to
127127 // canonicalize.
128- // Only do so if there are relative path components, otherwise symlinks to 'echo' may be resolved to their
129- // root program like 'coreutils' which relies on the executable name for proper function.
128+ // Only do so if there are relative path components
130129 let has_relative_path_components = candidate. components ( ) . any ( |c| {
131130 matches ! (
132131 c,
133132 std:: path:: Component :: ParentDir | std:: path:: Component :: CurDir
134133 )
135134 } ) ;
136135 return Ok ( if has_relative_path_components {
137- candidate. canonicalize ( ) ?
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
138152 } else {
139153 candidate
140154 } ) ;
You can’t perform that action at this time.
0 commit comments