Changeset 3232 in MondoRescue for branches/3.2/mindi-busybox/coreutils/test.c
- Timestamp:
- Jan 1, 2014, 12:47:38 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mindi-busybox/coreutils/test.c
r2725 r3232 40 40 //config: Enable 64-bit support in test. 41 41 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 42 65 #include "libbb.h" 43 66 #include <setjmp.h> … … 46 69 47 70 /* test_main() is called from shells, and we need to be extra careful here. 48 * This is true regardless of PREFER_APPLETS and S TANDALONE_SHELL71 * This is true regardless of PREFER_APPLETS and SH_STANDALONE 49 72 * state. */ 50 73 … … 588 611 589 612 /* Root can execute any file that has any one of the execute 590 613 * bits set. */ 591 614 if (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) 592 615 return 0; … … 688 711 /* special case: [ ! ], [ a -a ! ] are valid */ 689 712 /* 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]); 691 715 return 1; 692 716 } … … 707 731 nest_msg(">aexpr(%s)\n", TOKSTR[n]); 708 732 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]); 710 734 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]); 712 736 res = aexpr(check_operator(*++args)) && res; 713 737 unnest_msg("<aexpr:%lld\n", res); … … 715 739 } 716 740 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]); 718 742 return res; 719 743 } … … 726 750 nest_msg(">oexpr(%s)\n", TOKSTR[n]); 727 751 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]); 729 753 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]); 731 755 res = oexpr(check_operator(*++args)) || res; 732 756 unnest_msg("<oexpr:%lld\n", res); … … 734 758 } 735 759 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]); 737 761 return res; 738 762 } … … 879 903 880 904 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 */ 882 909 bb_error_msg("%s: unknown operand", *args); 883 910 res = 2;
Note:
See TracChangeset
for help on using the changeset viewer.