Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#55403 closed defect (invalid)

coreutils installs binary named g[

Reported by: mf2k (Frank Schima) Owned by:
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: ryandesign (Ryan Carsten Schmidt)
Port: coreutils

Description

$ port provides /opt/local/bin/g[
/opt/local/bin/g[ is provided by: coreutils

That binary name ("g[") seems unusual. I assume that is a bug in the Portfile?

Change History (2)

comment:1 Changed 7 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: ryandesign added
Resolution: invalid
Status: newclosed

Not a bug. [ is a legal binary name, and a normal component of UNIX systems. macOS ships with a copy of this binary at /bin/[.

When would you use a binary named [? For example in the following constructions:

$ if [ -x /opt/local/bin/port ]; then echo 'MacPorts is installed'; fi
MacPorts is installed
$ [ -x /opt/local/bin/port ] && echo 'MacPorts is installed'
MacPorts is installed

The coreutils port puts a g in front of every binary name, so it ends up as g[, which admittedly isn't going to get much use, but a symlink to it, named [, is in /opt/local/libexec/gnubin, and that might get more use. But you can still use it as g[ if you want, e.g.:

$ if g\[ -x /opt/local/bin/port ]; then echo 'MacPorts is installed'; fi
MacPorts is installed
$ g\[ -x /opt/local/bin/port ] && echo 'MacPorts is installed'
MacPorts is installed

[ is the same thing as test, with the exception that if you invoke it as [, you must supply a final argument ].

$ if test -x /opt/local/bin/port; then echo 'MacPorts is installed'; fi
MacPorts is installed
$ test -x /opt/local/bin/port && echo 'MacPorts is installed'
MacPorts is installed

comment:2 Changed 7 years ago by mf2k (Frank Schima)

Thank you for the clarification!

Note: See TracTickets for help on using tickets.