You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// <description><a href="https://earthsci.stanford.edu/computing/unix/shell/specialchars.php">Unix C-Shell special characters and their uses</a></description>
53
+
/// </item>
54
+
/// <item>
55
+
/// <description><a href="https://docstore.mik.ua/orelly/unix3/upt/ch27_13.htm">Differences Between Bourne and C Shell Quoting</a></description>
56
+
/// </item>
57
+
/// </list>
58
+
/// </para>
59
+
/// </remarks>
60
+
publicstaticstringShellQuote(thisstringvalue)
61
+
{
62
+
if(value==null)
63
+
{
64
+
thrownewArgumentNullException("value");
65
+
}
66
+
67
+
// result is at least value and leading/trailing single-quote
68
+
varsb=newStringBuilder(value.Length+2);
69
+
varstate=ShellQuoteState.Unquoted;
70
+
71
+
foreach(varcinvalue)
72
+
{
73
+
switch(c)
74
+
{
75
+
case'\'':
76
+
// embed a single-quote in quotes
77
+
switch(state)
78
+
{
79
+
caseShellQuoteState.Unquoted:
80
+
// Start quoted string
81
+
sb.Append('"');
82
+
break;
83
+
caseShellQuoteState.Quoted:
84
+
// Continue quoted string
85
+
break;
86
+
caseShellQuoteState.SingleQuoted:
87
+
// Close single quoted string
88
+
sb.Append('\'');
89
+
// Start quoted string
90
+
sb.Append('"');
91
+
break;
92
+
}
93
+
state=ShellQuoteState.Quoted;
94
+
break;
95
+
case'!':
96
+
// In C-Shell, an exclamatation point can only be protected from shell interpretation
0 commit comments