Fix in Linux

This commit is contained in:
Antonio de la Rosa 2026-01-05 22:55:44 +01:00
parent 6827724ee0
commit 334139cd25

View file

@ -5,6 +5,8 @@ namespace PhangoApp\CuchuluPHPUtils;
class Linux { class Linux {
static public $distros=['debian', 'ubuntu', 'fedora', 'arch'];
static public function shell_command($arr_command, $exit_if_error=1) { static public function shell_command($arr_command, $exit_if_error=1) {
$error=0; $error=0;
@ -240,19 +242,23 @@ class Linux {
} }
static public function sed($arr_sed) { static public function sed($arr_sed, $yes_error=1) {
$distro=Linux::get_linux_distro(); $distro=Linux::get_linux_distro();
if(!isset($arr_sed[$distro])) { if(!isset($arr_sed[$distro])) {
echo "Sorry, you don't have a sed str for this distro\n\n"; if($yes_error) {
exit(1); echo "Sorry, you don't have a sed str for this distro\n\n";
exit(1);
}
} }
return Linux::shell_command(["sudo sed -i", "\"s/".$arr_sed[$distro][0]."/".$arr_sed[$distro][1]."/g\" ".$arr_sed[$distro][2]]); return Linux::shell_command(["sudo sed -i", "\"s/".addslashes($arr_sed[$distro][0])."/".addslashes($arr_sed[$distro][1])."/g\" ".$arr_sed[$distro][2]]);
} }