Ignore:
Timestamp:
Feb 25, 2011, 9:26:54 PM (13 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mindi-busybox/coreutils/readlink.c

    r1765 r2725  
    55 * Copyright (C) 2000,2001 Matt Kraai <kraai@alumni.carnegiemellon.edu>
    66 *
    7  * Licensed under GPL v2 or later, see file LICENSE in this tarball for details.
     7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
     8 */
     9#include "libbb.h"
     10
     11/*
     12 * # readlink --version
     13 * readlink (GNU coreutils) 6.10
     14 * # readlink --help
     15 *   -f, --canonicalize
     16 *      canonicalize by following every symlink in
     17 *      every component of the given name recursively;
     18 *      all but the last component must exist
     19 *   -e, --canonicalize-existing
     20 *      canonicalize by following every symlink in
     21 *      every component of the given name recursively,
     22 *      all components must exist
     23 *   -m, --canonicalize-missing
     24 *      canonicalize by following every symlink in
     25 *      every component of the given name recursively,
     26 *      without requirements on components existence
     27 *   -n, --no-newline              do not output the trailing newline
     28 *   -q, --quiet, -s, --silent     suppress most error messages
     29 *   -v, --verbose                 report error messages
     30 *
     31 * bbox supports: -f -n -v (fully), -q -s (accepts but ignores)
    832 */
    933
    10 #include <getopt.h>
    11 
    12 #include "libbb.h"
    13 
    14 int readlink_main(int argc, char **argv);
    15 int readlink_main(int argc, char **argv)
     34int readlink_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
     35int readlink_main(int argc UNUSED_PARAM, char **argv)
    1636{
    1737    char *buf;
    1838    char *fname;
    1939
    20     USE_FEATURE_READLINK_FOLLOW(
     40    IF_FEATURE_READLINK_FOLLOW(
    2141        unsigned opt;
    2242        /* We need exactly one non-option argument.  */
    2343        opt_complementary = "=1";
    24         opt = getopt32(argv, "f");
     44        opt = getopt32(argv, "fnvsq");
    2545        fname = argv[optind];
    2646    )
    27     SKIP_FEATURE_READLINK_FOLLOW(
     47    IF_NOT_FEATURE_READLINK_FOLLOW(
    2848        const unsigned opt = 0;
    2949        if (argc != 2) bb_show_usage();
     
    3252
    3353    /* compat: coreutils readlink reports errors silently via exit code */
    34     logmode = LOGMODE_NONE;
     54    if (!(opt & 4)) /* not -v */
     55        logmode = LOGMODE_NONE;
    3556
    36     if (opt) {
    37         buf = realpath(fname, bb_common_bufsiz1);
     57    if (opt & 1) { /* -f */
     58        buf = xmalloc_realpath(fname);
    3859    } else {
    3960        buf = xmalloc_readlink_or_warn(fname);
     
    4263    if (!buf)
    4364        return EXIT_FAILURE;
    44     puts(buf);
     65    printf((opt & 2) ? "%s" : "%s\n", buf);
    4566
    46     if (ENABLE_FEATURE_CLEAN_UP && !opt)
     67    if (ENABLE_FEATURE_CLEAN_UP)
    4768        free(buf);
    4869
Note: See TracChangeset for help on using the changeset viewer.