Unbreak hack to strip " (deleted)" suffix from executable path

Commit 49b88868df (Fix stripping of " (deleted)" from non-UTF8 paths
to fish, 2024-10-12) was wrong because Path::ends_with() considers
entire path components. Fix that.

Refs:
- https://matrix.to/#/!YLTeaulxSDauOOxBoR:matrix.org/$k2IQazfmztFUXrairmIQvx_seS1ZJ7HlFWhmNy479Dg
- https://matrix.to/#/!YLTeaulxSDauOOxBoR:matrix.org/$4pugfHejL9J9L89zuFU6Bfg41UMjA0y79orc3EaBego
This commit is contained in:
Johannes Altmanninger
2025-10-02 10:02:26 +02:00
parent 97acc12d62
commit 7b59ae0d82

View File

@@ -1654,7 +1654,7 @@ pub fn get_executable_path(argv0: impl AsRef<Path>) -> PathBuf {
// When /proc/self/exe points to a file that was deleted (or overwritten on update!)
// then linux adds a " (deleted)" suffix.
// If that's not a valid path, let's remove that awkward suffix.
if !path.ends_with(" (deleted)") {
if path.as_os_str().as_bytes().ends_with(b" (deleted)") {
return path;
}