Carlo Arenas <carenas@xxxxxxxxx> writes: > On Sun, Sep 12, 2021 at 10:34 PM Bagas Sanjaya <bagasdotme@xxxxxxxxx> wrote: >> On 13/09/21 03.28, Carlo Marcelo Arenas Belón wrote: >> > test -S is not able to detect that a file is a socket, so use >> > test -f instead. >> >> Isn't test -f just check for socket as regular file? > > and that is exactly how they look; ironically a -f check in Linux > fails for sockets so maybe better to do -e? > > an empty file with nothing that indicates in Windows Explorer or a > stat call (from WSL or git bash), that they are anything else. It actually is a quite attractive idea to use "-e", or even more preferrably, test_path_exists. For example: @@ -31,7 +42,7 @@ helper_test cache test_expect_success "use custom XDG_CACHE_HOME if set and default sockets are not created" ' test_when_finished "git credential-cache exit" && - test -S "$XDG_CACHE_HOME/git/credential/socket" && + test $FLAG "$XDG_CACHE_HOME/git/credential/socket" && test_path_is_missing "$HOME/.git-credential-cache/socket" && test_path_is_missing "$HOME/.cache/git/credential/socket" ' test_path_exists contrasts better with the two test_path_is_missing and explains what is being tested better. Before this part, we have run some "git credential" test, and there are three possible places that the socket may appear (XDG, HOME/.git-credential-cache/ and HOME/.cache/git/credential/), and we want to make sure only one of them gets it. One possible downside is that it makes us rely more on our knowledge that we communicate via unix-domain socket (i.e. what the "socket" the test is checking is). By assuming that a mere presence of some filesystem entity at the inspected path is OK, we may not notice a breakage that creates a regular file or a directory there by mistake, yet successfully carry out the credential tests. It may even be a good thing, if future ourselves have somehow found out how to use a regular file or a directory for IPC instead of using a socket ;-). Thanks.