From a3ddb1ca51aad827bf141115370ad5b55e421336 Mon Sep 17 00:00:00 2001 From: 8nlight <8nlight@disroot.org> Date: Thu, 12 Oct 2023 16:17:40 +0300 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=B2=20=C2=AB?= =?UTF-8?q?src=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chroot.c | 4 ++-- src/mv.c | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 src/mv.c diff --git a/src/chroot.c b/src/chroot.c index 5fd4a02..9d25aae 100644 --- a/src/chroot.c +++ b/src/chroot.c @@ -6,8 +6,8 @@ int main(const int argc, const char **argv) { if (argc <= 2) { - fprintf(stderr, "chroot [dir] [\"command arg\"]\n"); - return 1; + printf("chroot [dir] [\"command arg\"]\n"); + return 0; } if (chroot(argv[1]) == -1) { diff --git a/src/mv.c b/src/mv.c new file mode 100644 index 0000000..c376a2e --- /dev/null +++ b/src/mv.c @@ -0,0 +1,21 @@ +#include +#include +#include +#include +#include + +int main(const int argc, char **argv) { + if (argc <= 2) { + printf("mv: missing operand\n"); + return 1; + } + + for (int i = 1; i < argc; i++) { + if (rename(argv[i], argv[argc]) < 0) { + fprintf(stderr, "mv: %s\n", strerror(errno)); + return 1; + } + } + + return 0; +}