From f82bfe0cbb0e8e22a051224c336d85d328de6588 Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Tue, 9 Jul 2024 15:03:11 +0800 Subject: [PATCH] Interpret home also on Linux --- include/xy.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/include/xy.h b/include/xy.h index c9c33bd..c5aaa57 100644 --- a/include/xy.h +++ b/include/xy.h @@ -637,15 +637,13 @@ _xy_win_powershellv5_profile () static bool xy_file_exist (const char *path) { - const char *newpath = path; - if (xy_on_windows) + const char *new_path = path; + if (xy_str_start_with (path, "~")) { - if (xy_str_start_with (path, "~")) - { - newpath = xy_2strjoin (xy_os_home, path + 1); - } + new_path = xy_2strjoin (xy_os_home, path + 1); } - return access (newpath, 0) ? false : true; + // 0 即 F_OK + return (0==access (new_path, 0)) ? true : false; } /**