Question about 'test'
Dik T. Winter
dik at cwi.nl
Tue Dec 4 23:15:50 AEST 1990
In article <987 at mwtech.UUCP> martin at mwtech.UUCP (Martin Weitzel) writes:
> In article <1779 at seti.inria.fr> deschamp at seti.inria.fr writes:
> :What I do not understand is this:
> : $ '['
> : test: ] missing
> : $ PATH=/bin '['
> : test: ] missing
> : $ /bin/[
> : $
>
> This shows exactly what original poster tried to say (as I understood).
> To make it a bit clearer, the source-code of "test" must look like
> if (!strcmp(argv[0], "[")) {
> if (strcmp(argv[--argc], "]") {
> /* complain about missing "]" and exit */
> .....
> }
> }
> /* parse arguments; run tests as required */
> .....
>
> In your last experiment argv[0] is "/bin/[" and not simply "[", hence no
> comlaint.
Exactly, just try:
[ -f foo ]
and
/bin/[ -f foo ]
--
dik t. winter, cwi, amsterdam, nederland
dik at cwi.nl
More information about the Comp.unix.shell
mailing list