diff --git a/src/misc.cpp b/src/misc.cpp index 87ab7a6..e51aa98 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -39,11 +39,9 @@ bool confirm_mount([[maybe_unused]] const std::string_view& part_user, bool quit detail::infobox_widget("\nMount Successful!\n"); std::this_thread::sleep_for(std::chrono::seconds(2)); } - // TODO: reimplement natively - const auto& str = utils::make_multiline(partitions); - const auto& cmd = fmt::format(FMT_COMPILE("echo \"{0}\" | sed \"s~{1} [0-9]*[G-M]~~\" | sed \"s~{1} [0-9]*\\.[0-9]*[G-M]~~\" | sed s~{1}$' -'~~"), str, partition); - const auto& res_text = utils::exec(cmd); - partitions = utils::make_multiline(res_text); + + // remove current mount from all partitions list + std::erase_if(partitions, [partition](std::string_view x) { return x.find(partition) != std::string_view::npos; }); number_partitions -= 1; return true; } diff --git a/src/tui.cpp b/src/tui.cpp index 1aed913..955143d 100644 --- a/src/tui.cpp +++ b/src/tui.cpp @@ -746,7 +746,7 @@ void bios_bootloader() { if (selected_bootloader.empty()) { return; } /* clang-format on */ - selected_bootloader = utils::exec(fmt::format(FMT_COMPILE("echo \"{}\" | sed 's/+ \\|\"//g'"), selected_bootloader)); + utils::remove_all(selected_bootloader, "+ "); /* clang-format off */ if (!tui::select_device()) { return; } @@ -1224,12 +1224,8 @@ void make_swap() noexcept { utils::exec(fmt::format(FMT_COMPILE("swapon {} &>/dev/null"), partition)); #endif - // TODO: reimplement natively // Since a partition was used, remove that partition from the list - const auto& str = utils::make_multiline(partitions); - const auto& cmd = fmt::format(FMT_COMPILE("echo \"{0}\" | sed \"s~{1} [0-9]*[G-M]~~\" | sed \"s~{1} [0-9]*\\.[0-9]*[G-M]~~\" | sed s~{1}$' -'~~"), str, partition); - const auto& res_text = utils::exec(cmd); - partitions = utils::make_multiline(res_text); + std::erase_if(partitions, [partition](std::string_view x) { return x.find(partition) != std::string_view::npos; }); number_partitions -= 1; }