Formatting a Drive with fmt
How to format a drive using {fmt}. #programmingtips #include <fmt/format.h> struct drive { std::string path; }; template <> struct fmt::formatter<drive> : fmt::formatter<int> { auto format(const drive& d, fmt::format_context& ctx) { auto command = fmt::format("sudo mkfs.ext4 {}", d.path); system(command.c_str()); return ctx.out(); } }; int main() { fmt::format("{}", drive("/dev/sda1")); }
A programming tips post shows C++ code that defines a custom {fmt} formatter for a drive. Formatting the drive secretly runs a sudo mkfs.ext4 command on /dev/sda1, which would erase and reformat the disk. The joke is a malicious or dangerously misleading code example disguised as a helpful formatting tutorial, suitable as a reaction to unsafe programming advice. EN: A programming tips post shows C++ code that defines a custom {fmt} formatter for a drive. Formatting the drive secretly runs a sudo mkfs.ext4 command on /dev/sda1, which would erase and reformat the disk. The joke is a malicious or dangerously misleading code example disguised as a helpful formatting tutorial, suitable as a reaction to unsafe programming advice.
- @ithueti / 2584 2020-07-27
- @right_wing_dev_squads / 3636 2022-03-13
- Type
- image
- Size
- 696×800 · 65.9 KiB
- Mood
- саркастичный, опасный
- Language
- en
- Added