macOS accepts socket paths of at most 103 characters. Count the folder, the file name, the 40-character hash and the temporary end ssh adds; when the total is over 103, leave the connection-sharing options out. Find, make and check the socket folder once per run instead of for every command.