diff --git a/phpmon/Domain/Core/Actions.swift b/phpmon/Domain/Core/Actions.swift index 08faea9..e2edd93 100644 --- a/phpmon/Domain/Core/Actions.swift +++ b/phpmon/Domain/Core/Actions.swift @@ -201,9 +201,14 @@ class Actions { { // Escape slashes (or `sed` won't work) let e_original = original.replacingOccurrences(of: "/", with: "\\/") - let e_replacment = replacement.replacingOccurrences(of: "/", with: "\\/") + let e_replacement = replacement.replacingOccurrences(of: "/", with: "\\/") - Shell.run("sed -i '' 's/\(e_original)/\(e_replacment)/g' \(file)") + // Check if gsed exists; it is able to follow symlinks, which we want to do to toggle the extension + if Shell.fileExists("\(Paths.binPath)/gsed") { + Shell.run("\(Paths.binPath)/gsed -i --follow-symlinks 's/\(e_original)/\(e_replacement)/g' \(file)") + } else { + Shell.run("sed -i '' 's/\(e_original)/\(e_replacement)/g' \(file)") + } } /**