From cd6c3ea1c3ca853fc38da4fa5fd62545c31aa92d Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng <deva@aasimon.org> Date: Thu, 3 Apr 2025 07:56:04 +0200 Subject: Refactor getenv usage. --- src/libctor.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/libctor.cc') diff --git a/src/libctor.cc b/src/libctor.cc index d72d82b..2685ec0 100644 --- a/src/libctor.cc +++ b/src/libctor.cc @@ -17,7 +17,6 @@ #include <cstdlib> #include <span> - #include "ctor.h" #include "configure.h" #include "rebuild.h" @@ -25,6 +24,7 @@ #include "build.h" #include "unittest.h" #include "argparser.h" +#include "util.h" int main(int argc, char* argv[]) { @@ -221,10 +221,16 @@ Options: return res; } - auto verbose_env = std::getenv("V"); - if(verbose_env) + if(std::string value; get_env("V", value)) { - settings.verbose = std::atoi(verbose_env); + try + { + settings.verbose = std::stoi(value); + } + catch(...) + { + // not an integer + } } if(list_files) -- cgit v1.2.3