0

I have a script /usr/local/bin/foo that opens an app with command line arguments:

#!/bin/bash

open -a Foo.app --args $@

The problem is, when I run

foo bar.txt

the result is Foo.app opens and tells me bar.txt cannot be found. However,

foo /absolute/path/to/bar.txt

works as expected.

Is there a simple way to automatically pass absolute paths to the --args option of the open command?

1 Answers1

0

Here is the simplest solution I could come up with

#!/bin/bash
for i in $@
do
     ARGS=`realpath $i`" $ARGS"
done

open -a Foo.app --args $ARGS