Guest User

Untitled

a guest
Sep 21st, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. class Program
  2. {
  3. const string script =
  4. @"#!/bin/bash
  5. echo Hello
  6. echo Hi
  7. echo Hey
  8. ";
  9.  
  10. static void Main(string[] args)
  11. {
  12. string text;
  13. if (args.Length > 0)
  14. {
  15. // This gets written as CRLF
  16. text = script;
  17. }
  18. else
  19. {
  20. // This gets written as LF(probably because StringBuilder figures
  21. // in which OS its running and does the right thing)
  22. var sb = new StringBuilder();
  23. sb.AppendLine("#!/bin/bash");
  24. sb.AppendLine("echo Hello");
  25. sb.AppendLine("echo Hi");
  26. sb.AppendLine("echo Hey");
  27. text = sb.ToString();
  28. }
  29.  
  30. var path = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid().ToString("N")}.sh");
  31. File.WriteAllText(path, text);
  32. Console.WriteLine($"Text written to {path}");
  33. }
  34. }
Add Comment
Please, Sign In to add comment