m95d
1
I upgraded from r23611 to r23885. I changed busybox "Test builtin" to off.
One of my scripts isn't working anymore:
# [[ -r /tmp/ddns_ip ]] ; echo $?
0
# [[ -w /tmp/ddns_ip ]] ; echo $?
0
# [[ -r /tmp/ddns_ip && -w /tmp/ddns_ip ]] ; echo $?
[[: missing ]]
2
Is this a bug or am I doing something really stupid at this late hour of the night?
Thanks!
[[
is an alias for the busybox test
command. Does single bracket still work?
m95d
3
I know it's the same, that's why I mentioned that change.
Single bracket doesn't work. AFAIK, it's also the same as test and double bracket.
slh
5
[[
is a bashism and not defined in POSIX shell, don't use it.
7 Likes
m95d
6
Thank you both. I didn't know that. I always thought that [[ is a more advanced version of [ and that busybox uses [[ for both.
I wonder why it worked with "Test builtin" config option? Or maybe there was some other change that I made?
egc
7
Maybe this works?
[[ -r /tmp/ddns_ip && -w /tmp/ddns_ip ]] && echo $?
slh
8
There is no reason not to use:
if [ -r /tmp/ddns_ip ] && [ -w /tmp/ddns_ip ]; then
echo 0 1>&2
else
echo 1 1>&2
fi
and keep it POSIX compliant.
2 Likes