Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- const string script =
- @"#!/bin/bash
- echo Hello
- echo Hi
- echo Hey
- ";
- static void Main(string[] args)
- {
- string text;
- if (args.Length > 0)
- {
- // This gets written as CRLF
- text = script;
- }
- else
- {
- // This gets written as LF(probably because StringBuilder figures
- // in which OS its running and does the right thing)
- var sb = new StringBuilder();
- sb.AppendLine("#!/bin/bash");
- sb.AppendLine("echo Hello");
- sb.AppendLine("echo Hi");
- sb.AppendLine("echo Hey");
- text = sb.ToString();
- }
- var path = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid().ToString("N")}.sh");
- File.WriteAllText(path, text);
- Console.WriteLine($"Text written to {path}");
- }
- }
Add Comment
Please, Sign In to add comment