diff options
author | jozan <jozan@noemail.net> | 2020-11-15 16:24:21 +0000 |
---|---|---|
committer | jozan <jozan@noemail.net> | 2020-11-15 16:24:21 +0000 |
commit | d08c2c074117f8171370a8d3e12f13a3e17d24f0 (patch) | |
tree | aa21a515374c6664d18cac50ebf3c95c82f91af2 | |
parent | Man in progress (diff) | |
download | unixize-d08c2c074117f8171370a8d3e12f13a3e17d24f0.tar.gz unixize-d08c2c074117f8171370a8d3e12f13a3e17d24f0.tar.bz2 unixize-d08c2c074117f8171370a8d3e12f13a3e17d24f0.tar.xz unixize-d08c2c074117f8171370a8d3e12f13a3e17d24f0.tar.zst unixize-d08c2c074117f8171370a8d3e12f13a3e17d24f0.zip |
A directory is now a required argument, for safety
FossilOrigin-Name: ff2d65680f254c7930990b40e3988f9b0443cd5dd58e852e5b13e0989de4d206
-rw-r--r-- | man/unixize.1 | 1 | ||||
-rw-r--r-- | src/c_opts.c | 15 | ||||
-rw-r--r-- | src/c_opts.h | 2 | ||||
-rw-r--r-- | src/c_unixize.c | 20 |
4 files changed, 22 insertions, 16 deletions
diff --git a/man/unixize.1 b/man/unixize.1 index 75057bb..29d65cd 100644 --- a/man/unixize.1 +++ b/man/unixize.1 @@ -119,5 +119,6 @@ relevant ascii character (or double characters). .SH OPTIONS .SH SEE ALSO .IR ascii (1), +.IR ls (1), .IR rename (2) .\" vim: set filetype=groff: diff --git a/src/c_opts.c b/src/c_opts.c index 6df0722..996643e 100644 --- a/src/c_opts.c +++ b/src/c_opts.c @@ -190,7 +190,7 @@ c_get_opts C_C_OPT_FMT, optarg ); - exit(2); + exit(1); } else { opts->cxx = optarg[0] - 48; @@ -203,18 +203,23 @@ c_get_opts } if ( argv[0][0] != C_RECURSIVE_CHAR && + argv[optind] == NULL + ) { + c_dump_usage(); + exit(1); + } + if ( + argv[0][0] != C_RECURSIVE_CHAR && optind < argc && argv[optind] != NULL - ) { + ) { strncpy(opts->dir, argv[optind], PATH_MAX); if (opts->dir[strlen(opts->dir) - 1] == '/') { opts->dir[strlen(opts->dir) - 1] = 0x00; } } - else if (argv[0][0] == C_RECURSIVE_CHAR || argv[optind] == NULL) { + else if (argv[0][0] == C_RECURSIVE_CHAR) { strlcpy(opts->dir, ".", 2 * sizeof(char)); - } - if (argv[0][0] == C_RECURSIVE_CHAR) { c_recursive_parse(opts, argv); } ret = TRUE; diff --git a/src/c_opts.h b/src/c_opts.h index 029fcaa..92788ed 100644 --- a/src/c_opts.h +++ b/src/c_opts.h @@ -51,7 +51,7 @@ #define C_OPTS "ahiknprRve:" #define C_RECURSIVE_CHAR 'r' #define C_USAGE_FMT \ - "usage: unixize [-ahiknprRv] [-e ext] [directory]\n" + "usage: unixize [-ahiknprRv] [-e ext] directory\n" #define C_C_OPT_FMT \ "unixize: unsupported -e value '%s' (must be always 0, 1 or 2)\n" diff --git a/src/c_unixize.c b/src/c_unixize.c index b444ec3..84c4371 100644 --- a/src/c_unixize.c +++ b/src/c_unixize.c @@ -152,16 +152,16 @@ main ); } if (opts.pretend == FALSE) { - if (rename(og_files->filename, new_files->filename) == -1) { - dprintf( - STDERR_FILENO, - "unixize: rename %s to %s: %s\n", - og_files->filename, - new_files->filename, - strerror(errno) - ); - ret = 2; - } + /* if (rename(og_files->filename, new_files->filename) == -1) { */ + /* dprintf( */ + /* STDERR_FILENO, */ + /* "unixize: rename %s to %s: %s\n", */ + /* og_files->filename, */ + /* new_files->filename, */ + /* strerror(errno) */ + /* ); */ + /* ret = 2; */ + /* } */ } } else if (opts.rverbose == TRUE) { |