Date: Mon, 29 Jul 2013 15:54:01 +0200 From: Polytropon <freebsd@edvax.de> To: Paul Macdonald <paul@ifdnrg.com> Cc: "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org> Subject: Re: Unusual file: /bin/[ Message-ID: <20130729155401.ec663cb5.freebsd@edvax.de> In-Reply-To: <51F66D34.8010803@ifdnrg.com> References: <51F66D34.8010803@ifdnrg.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 29 Jul 2013 14:25:08 +0100, Paul Macdonald wrote: > > Hi, I spotted what i'd call an unusual file in the basejail on a jail > install, and have since seen this on other non jailed boxes. > > -r-xr-xr-x 2 root wheel 11488 Jun 10 12:19 [ > > man [ reveals > > test, [ -- condition evaluation utility > > just checking thats all ok, and i've not been rooted! The "[" program is the same as the "test" program. It's a valid file name and it's often used in shell scripts instead of "test". % ll /bin/test /bin/\[ -r-xr-xr-x 2 root wheel 8336 2011-08-21 20:23:20 /bin/[* -r-xr-xr-x 2 root wheel 8336 2011-08-21 20:23:20 /bin/test* Consider shell scripts. When you have a script with something like if [ -f bla.txt ]; then ... some stuff ... fi it is the same as if test -f bla.txt; then ... some stuff ... fi It's also often being used like [ -x blah.sh ] && do_something which is identical to calling "test" and acting upon the value of the return code. Nothing to worry here. YOu can _always_ counter-check by building /usr/src/bin/test from source and compare the resulting binary. Both /bin/[ and /bin/test are usually installed as hardlinks (two file names for one / for _the same_ file), as seen in the corresponding Makefile: LINKS= ${BINDIR}/test ${BINDIR}/[ So it's not _that_ unusual. ;-) -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130729155401.ec663cb5.freebsd>