[MacPorts] #55403: coreutils installs binary named g[

MacPorts noreply at macports.org
Fri Nov 24 16:50:51 UTC 2017


#55403: coreutils installs binary named g[
------------------------+--------------------
  Reporter:  mf2k       |      Owner:
      Type:  defect     |     Status:  closed
  Priority:  Normal     |  Milestone:
 Component:  ports      |    Version:
Resolution:  invalid    |   Keywords:
      Port:  coreutils  |
------------------------+--------------------
Changes (by ryandesign):

 * cc: ryandesign (added)
 * status:  new => closed
 * resolution:   => invalid


Comment:

 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
 }}}

--
Ticket URL: <https://trac.macports.org/ticket/55403#comment:1>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list