summaryrefslogtreecommitdiff
path: root/coreutils/ln.c
diff options
context:
space:
mode:
authorDenys Vlasenko2009-11-28 15:18:53 +0100
committerDenys Vlasenko2009-11-28 15:18:53 +0100
commite992bae6f9adf3718c6263a36c004ead1c7272a8 (patch)
treef0bc9e4fa145f58ab3f9838902e09f9cfba29648 /coreutils/ln.c
parent86cfb70ca5f2bde11f2d071bc59db75291d8552f (diff)
downloadbusybox-e992bae6f9adf3718c6263a36c004ead1c7272a8.zip
busybox-e992bae6f9adf3718c6263a36c004ead1c7272a8.tar.gz
*: remove a few more cases of argc usage. -89 bytes.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils/ln.c')
-rw-r--r--coreutils/ln.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/coreutils/ln.c b/coreutils/ln.c
index eb71719..f977aa1 100644
--- a/coreutils/ln.c
+++ b/coreutils/ln.c
@@ -26,7 +26,7 @@ int ln_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int ln_main(int argc, char **argv)
{
int status = EXIT_SUCCESS;
- int flag;
+ int opts;
char *last;
char *src_name;
char *src;
@@ -34,11 +34,8 @@ int ln_main(int argc, char **argv)
struct stat statbuf;
int (*link_func)(const char *, const char *);
- flag = getopt32(argv, "sfnbS:", &suffix);
-
- if (argc == optind) {
- bb_show_usage();
- }
+ opt_complementary = "-1"; /* min one arg */
+ opts = getopt32(argv, "sfnbS:", &suffix);
last = argv[argc - 1];
argv += optind;
@@ -53,7 +50,7 @@ int ln_main(int argc, char **argv)
src = last;
if (is_directory(src,
- (flag & LN_NODEREFERENCE) ^ LN_NODEREFERENCE,
+ (opts & LN_NODEREFERENCE) ^ LN_NODEREFERENCE,
NULL)
) {
src_name = xstrdup(*argv);
@@ -61,7 +58,7 @@ int ln_main(int argc, char **argv)
free(src_name);
src_name = src;
}
- if (!(flag & LN_SYMLINK) && stat(*argv, &statbuf)) {
+ if (!(opts & LN_SYMLINK) && stat(*argv, &statbuf)) {
// coreutils: "ln dangling_symlink new_hardlink" works
if (lstat(*argv, &statbuf) || !S_ISLNK(statbuf.st_mode)) {
bb_simple_perror_msg(*argv);
@@ -71,7 +68,7 @@ int ln_main(int argc, char **argv)
}
}
- if (flag & LN_BACKUP) {
+ if (opts & LN_BACKUP) {
char *backup;
backup = xasprintf("%s%s", src, suffix);
if (rename(src, backup) < 0 && errno != ENOENT) {
@@ -87,12 +84,12 @@ int ln_main(int argc, char **argv)
* Therefore, always unlink().
*/
unlink(src);
- } else if (flag & LN_FORCE) {
+ } else if (opts & LN_FORCE) {
unlink(src);
}
link_func = link;
- if (flag & LN_SYMLINK) {
+ if (opts & LN_SYMLINK) {
link_func = symlink;
}