mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-04-24 18:38:39 +03:00
20 lines
542 B
Swift
20 lines
542 B
Swift
extension Ghostty {
|
|
struct Shell {
|
|
// Characters to escape in the shell.
|
|
static let escapeCharacters = "\\ ()[]{}<>\"'`!#$&;|*?\t"
|
|
|
|
/// Escape shell-sensitive characters in string.
|
|
static func escape(_ str: String) -> String {
|
|
var result = str
|
|
for char in escapeCharacters {
|
|
result = result.replacingOccurrences(
|
|
of: String(char),
|
|
with: "\\\(char)"
|
|
)
|
|
}
|
|
|
|
return result
|
|
}
|
|
}
|
|
}
|