logo

utils-std

Collection of commonly available Unix tools
commit: c7b022a8301f736da32b4605ee7f4869ea9587f9
parent 26cee270a8fe71ba30cd98df65b3dbbef9658caa
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sat, 11 May 2024 18:39:38 +0200

cmd/mv: Initialize locales

This way consentf works as expected

Diffstat:

Mcmd/mv.c9+++++++++
1 file changed, 9 insertions(+), 0 deletions(-)

diff --git a/cmd/mv.c b/cmd/mv.c @@ -12,6 +12,7 @@ #include <assert.h> #include <errno.h> #include <fcntl.h> // open +#include <locale.h> // setlocale #include <stdbool.h> #include <stdint.h> // SIZE_MAX #include <stdio.h> // fprintf, rename @@ -219,6 +220,14 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; + errno = 0; + setlocale(LC_ALL, ""); + if(errno != 0) + { + fprintf(stderr, "%s: Warning: Failed to initialize locales: %s\n", argv0, strerror(errno)); + errno = 0; + } + consent_init(); if(destdir.fd == AT_FDCWD)