From 34900f929feaed7cddb38c9cade9a641918626d9 Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Sat, 13 Nov 2021 21:18:01 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Use=20gsed=20so=20we=20can=20follow?= =?UTF-8?q?=20symlinks=20to=20.ini=20files=20(#39,=20#47)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- phpmon/Domain/Core/Actions.swift | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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)") + } } /**