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/debianutils/mktemp.c

    r1765 r2725  
    77 * Written by Daniel Jacobowitz <dan@debian.org>
    88 *
    9  * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
     9 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    1010 */
     11
     12/* Coreutils 6.12 man page says:
     13 *        mktemp [OPTION]... [TEMPLATE]
     14 * Create a temporary file or directory, safely, and print its name. If
     15 * TEMPLATE is not specified, use tmp.XXXXXXXXXX.
     16 * -d, --directory
     17 *        create a directory, not a file
     18 * -q, --quiet
     19 *        suppress diagnostics about file/dir-creation failure
     20 * -u, --dry-run
     21 *        do not create anything; merely print a name (unsafe)
     22 * --tmpdir[=DIR]
     23 *        interpret TEMPLATE relative to DIR. If DIR is not specified,
     24 *        use  $TMPDIR if set, else /tmp.  With this option, TEMPLATE must
     25 *        not be an absolute name. Unlike with -t, TEMPLATE may contain
     26 *        slashes, but even here, mktemp still creates only the final com-
     27 *        ponent.
     28 * -p DIR use DIR as a prefix; implies -t [deprecated]
     29 * -t     interpret TEMPLATE as a single file name component, relative  to
     30 *        a  directory:  $TMPDIR, if set; else the directory specified via
     31 *        -p; else /tmp [deprecated]
     32 */
     33
    1134
    1235#include "libbb.h"
    1336
    14 int mktemp_main(int argc, char **argv);
    15 int mktemp_main(int argc, char **argv)
     37int mktemp_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
     38int mktemp_main(int argc UNUSED_PARAM, char **argv)
    1639{
    17     unsigned long flags = getopt32(argv, "dqt");
     40    const char *path;
    1841    char *chp;
     42    unsigned opts;
    1943
    20     if (optind + 1 != argc)
    21         bb_show_usage();
     44    path = getenv("TMPDIR");
     45    if (!path || path[0] == '\0')
     46        path = "/tmp";
    2247
    23     chp = argv[optind];
     48    /* -q and -t are ignored */
     49    opt_complementary = "?1"; /* 1 argument max */
     50    opts = getopt32(argv, "dqtp:", &path);
    2451
    25     if (flags & 4) {
    26         char *dir = getenv("TMPDIR");
    27         if (dir && *dir != '\0')
    28             chp = concat_path_file(dir, chp);
    29         else
    30             chp = concat_path_file("/tmp/", chp);
    31     }
     52    chp = argv[optind] ? argv[optind] : xstrdup("tmp.XXXXXX");
     53    if (!strchr(chp, '/') || (opts & 8))
     54        chp = concat_path_file(path, chp);
    3255
    33     if (flags & 1) {
     56    if (opts & 1) { /* -d */
    3457        if (mkdtemp(chp) == NULL)
    3558            return EXIT_FAILURE;
Note: See TracChangeset for help on using the changeset viewer.