Avoid infinite loop with large current working directory paths