Skip to content

Commit 06eaf5f

Browse files
committed
Add a line for version tracking
Signed-off-by: SupeChicken666 <me@supechicken666.dev>
1 parent 142e75d commit 06eaf5f

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/main.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
cc ./crew-mvdir.c -O3 -flto -o crew-mvdir
2929
*/
3030

31+
#define CREW_MVDIR_VERSION "0.4"
32+
3133
#include <stdio.h>
3234
#include <stdlib.h>
3335
#include <stdbool.h>
@@ -39,6 +41,11 @@ int main(int argc, char** argv) {
3941
struct mvdir_opts opts = {0};
4042
int opt;
4143

44+
if (argc == 2 && strcmp(argv[1], "--version") == 0) {
45+
fprintf(stderr, CREW_MVDIR_VERSION "\n");
46+
return 0;
47+
}
48+
4249
while ((opt = getopt(argc, argv, "vnc")) != -1) {
4350
switch (opt) {
4451
case 'c':
@@ -62,7 +69,7 @@ int main(int argc, char** argv) {
6269

6370
if (argc - optind != 2) {
6471
fprintf(stderr, "Usage: %s [-c] [-n] [-v] [src] [dst]\n", argv[0]);
65-
exit(EXIT_FAILURE);
72+
return EXIT_FAILURE;
6673
}
6774

6875
strcpy(opts.src, argv[optind]);

src/mvdir.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ int move_path(const char *src_path, const struct stat *src_info, int flag, struc
109109

110110
if (dst_exist && S_ISDIR(dst_info.st_mode)) {
111111
fprintf(stderr, "%s: cannot overwrite directory with non-directory\n", dst_path);
112-
exit(1);
112+
exit(EXIT_FAILURE);
113113
}
114114

115115
if (dst_exist && remove(dst_path) == -1) {
@@ -142,7 +142,7 @@ int move_path(const char *src_path, const struct stat *src_info, int flag, struc
142142
case FTW_D:
143143
if (dst_exist && !S_ISDIR(dst_info.st_mode)) {
144144
fprintf(stderr, "%s: cannot overwrite non-directory with directory\n", dst_path);
145-
exit(1);
145+
exit(EXIT_FAILURE);
146146
}
147147

148148
if (!dst_exist) {

0 commit comments

Comments
 (0)