While logically, a host's config should always appear after the host is declared, meaning the map is typically not nil, there's an edge case where the map remains uninitialized. This happens if the input only contains a single non-comment line, such as:
Include ~/.ssh/config.d/*
In this case, the Config map is not initialized, leading to the following error: panic: assignment to entry in nil map.
A check should be added to ensure the map is initialized before assignment.
Additionally, I believe the current directory reading mechanism could introduce several potential bugs, such as reading files like known_hosts which should not be processed. I think only configuration files should be read.
Of course, if you believe I should only operate on directories that exclusively contain configuration files, such as config.d, then the issue mentioned above would not arise. However, I still believe that since the design goal of this program is to simplify ssh configuration files, it should recursively start from the .ssh/config file, read all configurations, and process them accordingly.
In the
GroupSSHConfigFromString
function, the linehostConfigs[currentHost].Config[key] = value
does not check whether thehostConfigs[currentHost].Config
map is nil.While logically, a host's config should always appear after the host is declared, meaning the map is typically not nil, there's an edge case where the map remains uninitialized. This happens if the input only contains a single non-comment line, such as:
In this case, the
Config
map is not initialized, leading to the following error:panic: assignment to entry in nil map
.A check should be added to ensure the map is initialized before assignment.
Additionally, I believe the current directory reading mechanism could introduce several potential bugs, such as reading files like
known_hosts
which should not be processed. I think only configuration files should be read.Of course, if you believe I should only operate on directories that exclusively contain configuration files, such as
config.d
, then the issue mentioned above would not arise. However, I still believe that since the design goal of this program is to simplifyssh
configuration files, it should recursively start from the.ssh/config
file, read all configurations, and process them accordingly.