On 15/01/15 09:28, Colin Guthrie wrote:
> Although if the script is in bash I'd use  "if [ -d ..." rather than "if
> test -d ..." as (and bash experts (Harald?) can correct me here if I'm
> wrong) I believe [ is a bash built in (even if it is a binary in
> /usr/bin/), whereas it would have to fork out to run "test".

bash, dash, zsh and busybox sh all have both "test" and "[" as builtins,
at least as they're configured on Debian (and presumably Ubuntu too). No
idea about more obscure shells like ksh, but there's really no good
reason to implement one and not the other.

GNU coreutils provides /usr/bin/test and /usr/bin/[ as a fallback, but
they'd rarely be used.

Here's how you tell:

smcv@archetype:~$ type [
[ is a shell builtin
smcv@archetype:~$ type test
test is a shell builtin
smcv@archetype:~$ type dd       # a random non-builtin for comparison
dd is /bin/dd

    S

_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to