avoid empty lines being added to .ssh/config file
This commit is contained in:
parent
4b2b273783
commit
bb1d277cb0
|
@ -141,17 +141,17 @@ namespace SparkleLib {
|
||||||
|
|
||||||
string ssh_config_path = Path.Combine (path, ".ssh");
|
string ssh_config_path = Path.Combine (path, ".ssh");
|
||||||
string ssh_config_file_path = SparkleHelpers.CombineMore (path, ".ssh", "config");
|
string ssh_config_file_path = SparkleHelpers.CombineMore (path, ".ssh", "config");
|
||||||
string ssh_config = Environment.NewLine + "# <SparkleShare>" +
|
string ssh_config = "\n# <SparkleShare>" +
|
||||||
Environment.NewLine + "Host " + host +
|
"\nHost " + host +
|
||||||
Environment.NewLine + "\tStrictHostKeyChecking no" +
|
"\n\tStrictHostKeyChecking no" +
|
||||||
Environment.NewLine + "# </SparkleShare>";
|
"\n# </SparkleShare>";
|
||||||
|
|
||||||
if (!Directory.Exists (ssh_config_path))
|
if (!Directory.Exists (ssh_config_path))
|
||||||
Directory.CreateDirectory (ssh_config_path);
|
Directory.CreateDirectory (ssh_config_path);
|
||||||
|
|
||||||
if (File.Exists (ssh_config_file_path)) {
|
if (File.Exists (ssh_config_file_path)) {
|
||||||
TextWriter writer = File.AppendText (ssh_config_file_path);
|
TextWriter writer = File.AppendText (ssh_config_file_path);
|
||||||
writer.WriteLine (ssh_config);
|
writer.Write (ssh_config);
|
||||||
writer.Close ();
|
writer.Close ();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -182,7 +182,7 @@ namespace SparkleLib {
|
||||||
string current_ssh_config = File.ReadAllText (ssh_config_file_path);
|
string current_ssh_config = File.ReadAllText (ssh_config_file_path);
|
||||||
|
|
||||||
current_ssh_config = current_ssh_config.Trim ();
|
current_ssh_config = current_ssh_config.Trim ();
|
||||||
string [] lines = current_ssh_config.Split (Environment.NewLine.ToCharArray ());
|
string [] lines = current_ssh_config.Split ('\n');
|
||||||
string new_ssh_config = "";
|
string new_ssh_config = "";
|
||||||
bool in_sparkleshare_section = false;
|
bool in_sparkleshare_section = false;
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ namespace SparkleLib {
|
||||||
if (in_sparkleshare_section)
|
if (in_sparkleshare_section)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
new_ssh_config += line + Environment.NewLine;
|
new_ssh_config += line + "\n"; // do not use Environment.NewLine because file is in unix format
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty (new_ssh_config.Trim ())) {
|
if (string.IsNullOrEmpty (new_ssh_config.Trim ())) {
|
||||||
|
|
Loading…
Reference in a new issue