Changeset 3232 in MondoRescue for branches/3.2/mindi-busybox/coreutils/test.c


Ignore:
Timestamp:
Jan 1, 2014, 12:47:38 AM (10 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.21.1
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mindi-busybox/coreutils/test.c

    r2725 r3232  
    4040//config:     Enable 64-bit support in test.
    4141
     42/* "test --help" does not print help (POSIX compat), only "[ --help" does.
     43 * We display "<applet> EXPRESSION ]" here (not "<applet> EXPRESSION")
     44 * Unfortunately, it screws up generated BusyBox.html. TODO. */
     45//usage:#define test_trivial_usage
     46//usage:       "EXPRESSION ]"
     47//usage:#define test_full_usage "\n\n"
     48//usage:       "Check file types, compare values etc. Return a 0/1 exit code\n"
     49//usage:       "depending on logical value of EXPRESSION"
     50//usage:
     51//usage:#define test_example_usage
     52//usage:       "$ test 1 -eq 2\n"
     53//usage:       "$ echo $?\n"
     54//usage:       "1\n"
     55//usage:       "$ test 1 -eq 1\n"
     56//usage:       "$ echo $?\n"
     57//usage:       "0\n"
     58//usage:       "$ [ -d /etc ]\n"
     59//usage:       "$ echo $?\n"
     60//usage:       "0\n"
     61//usage:       "$ [ -d /junk ]\n"
     62//usage:       "$ echo $?\n"
     63//usage:       "1\n"
     64
    4265#include "libbb.h"
    4366#include <setjmp.h>
     
    4669
    4770/* test_main() is called from shells, and we need to be extra careful here.
    48  * This is true regardless of PREFER_APPLETS and STANDALONE_SHELL
     71 * This is true regardless of PREFER_APPLETS and SH_STANDALONE
    4972 * state. */
    5073
     
    588611
    589612        /* Root can execute any file that has any one of the execute
    590            bits set. */
     613         * bits set. */
    591614        if (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))
    592615            return 0;
     
    688711            /* special case: [ ! ], [ a -a ! ] are valid */
    689712            /* IOW, "! ARG" may miss ARG */
    690             unnest_msg("<nexpr:1 (!EOI)\n");
     713            args--;
     714            unnest_msg("<nexpr:1 (!EOI), args:%s(%p)\n", args[0], &args[0]);
    691715            return 1;
    692716        }
     
    707731    nest_msg(">aexpr(%s)\n", TOKSTR[n]);
    708732    res = nexpr(n);
    709     dbg_msg("aexpr: nexpr:%lld, next args:%s\n", res, args[1]);
     733    dbg_msg("aexpr: nexpr:%lld, next args:%s(%p)\n", res, args[1], &args[1]);
    710734    if (check_operator(*++args) == BAND) {
    711         dbg_msg("aexpr: arg is AND, next args:%s\n", args[1]);
     735        dbg_msg("aexpr: arg is AND, next args:%s(%p)\n", args[1], &args[1]);
    712736        res = aexpr(check_operator(*++args)) && res;
    713737        unnest_msg("<aexpr:%lld\n", res);
     
    715739    }
    716740    args--;
    717     unnest_msg("<aexpr:%lld, args:%s\n", res, args[0]);
     741    unnest_msg("<aexpr:%lld, args:%s(%p)\n", res, args[0], &args[0]);
    718742    return res;
    719743}
     
    726750    nest_msg(">oexpr(%s)\n", TOKSTR[n]);
    727751    res = aexpr(n);
    728     dbg_msg("oexpr: aexpr:%lld, next args:%s\n", res, args[1]);
     752    dbg_msg("oexpr: aexpr:%lld, next args:%s(%p)\n", res, args[1], &args[1]);
    729753    if (check_operator(*++args) == BOR) {
    730         dbg_msg("oexpr: next arg is OR, next args:%s\n", args[1]);
     754        dbg_msg("oexpr: next arg is OR, next args:%s(%p)\n", args[1], &args[1]);
    731755        res = oexpr(check_operator(*++args)) || res;
    732756        unnest_msg("<oexpr:%lld\n", res);
     
    734758    }
    735759    args--;
    736     unnest_msg("<oexpr:%lld, args:%s\n", res, args[0]);
     760    unnest_msg("<oexpr:%lld, args:%s(%p)\n", res, args[0], &args[0]);
    737761    return res;
    738762}
     
    879903
    880904    if (*args != NULL && *++args != NULL) {
    881         /* TODO: example when this happens? */
     905        /* Examples:
     906         * test 3 -lt 5 6
     907         * test -t 1 2
     908         */
    882909        bb_error_msg("%s: unknown operand", *args);
    883910        res = 2;
Note: See TracChangeset for help on using the changeset viewer.