Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Run certain apps based on login location' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Run certain apps based on login location
Authored by: Brock Lee on Mar 30, '05 10:17:43AM

But when I exit pico from my other terminal, I see an error: -bash: test: ==: unary operator expected What's happening is that the `echo $TERM_PROGRAM` is displaying "" (an empty string), which test doesn't like on the left hand side of a == operator.

You can put double quotes around the backquoted expression to deal with this. So here's your code with the double quotes added on the third line. It's important to remember that within double quotes, both back-quotes and dollar signs still do their magic (which is not true for single quotes).

function edit
{
  if test "`echo $TERM_PROGRAM`" == 'Apple_Terminal' ; then
      open -a 'SubEthaEdit.app' "$*" &
  else
      pico "$*"
  fi
}



[ Reply to This | # ]
Run certain apps based on login location
Authored by: Titanium Man on Mar 30, '05 12:18:31PM

Or you can use double brackets [[ ]] to test (rather than single brackets [ ]):

edit() {
if [[ ${TERM_PROGRAM} == 'Apple_Terminal' ]]; then
open -a 'SubEthaEdit.app' "$*" &
else
pico "$*"
fi
}



[ Reply to This | # ]