#!/bin/bash

######################################################################
#                                                                    #
#  Copyright (c) 2002, 2026 NoMachine, http://www.nomachine.com.     #
#                                                                    #
#  All rights reserved.                                              #
#                                                                    #
######################################################################

if test -z "$NX_SYSTEM"; then

  RUNDIR="${0%nxrunner}"
  BINDIR="$(cd "$RUNDIR" && pwd)"

  NX_SYSTEM="${BINDIR%/bin}"
  export NX_SYSTEM

fi

if test $# -gt 0; then

  #
  # Leopard's version of open doesn't support
  # the --args parameter.
  #

  exec "${NX_SYSTEM}/bin/nxrunner.app/Contents/MacOS/nxrunner" "$@"

else

  open -n "${NX_SYSTEM}/bin/nxrunner.app/Contents/MacOS/nxrunner"

fi

