3

I have LibreOffice Writer and OpenOffice Calc installed on my OpenSuSE system. This is arguably not ideal, but before I fully switch to one or the other, I noticed some strange behaviour when calling oocalc file.ods from the command line.

user@host:~> ooffice -calc
Warning: -calc is deprecated.  Use --calc instead.
user@host:~> oocalc
Warning: -calc is deprecated.  Use --calc instead.
user@host:~> which oocalc
/usr/bin/oocalc
user@host:~> readlink -f `which oocalc`
/opt/openoffice4/program/scalc
user@host:~> /usr/bin/oocalc
Warning: -calc is deprecated.  Use --calc instead.
user@host:~> ls -lth /usr/bin/oo*
lrwxrwxrwx 1 root root 30 Jan 30 17:32 /usr/bin/oocalc -> /opt/openoffice4/program/scalc
-rwxr-xr-x 2 root root 55 Dec 19 18:06 /usr/bin/ooffice
-rwxr-xr-x 2 root root 66 Dec 19 18:06 /usr/bin/oofromtemplate
-rwxr-xr-x 2 root root 60 Dec 19 18:06 /usr/bin/ooweb
-rwxr-xr-x 2 root root 63 Dec 19 18:06 /usr/bin/oowriter
user@host:~> readlink -f `which oocalc`
/opt/openoffice4/program/scalc
user@host:~> /opt/openoffice4/program/scalc

The last of the above commands runs OpenOffice Calc as expected. When oocalc or ooffice -calc is executed it prints the deprecation warning and then actually opens LibreOffice writer, as its spreadsheet counterpart isn't installed. My question, though, is how is it possible for oocalc to resolve correctly to the symbolic link but not follow it, and execute ooffice -calc instead?

EDIT: The contents of /opt/openoffice4/program/scalc are as follows:

cmd=$(cd `dirname $0` && pwd)/soffice
exec "$cmd" -calc "$@"
Barmar
  • 9,648
  • 1
  • 19
  • 28
ATG
  • 131
  • 3
  • 3
    What are the contents of `/opt/openoffice4/program/scalc`? My guess is that the symbolic link is being followed but the target is looking at `$0` and basing its incorrect behavior on that value. – Mark Plotnick Jan 30 '15 at 20:07
  • Mark, thanks, I didn't think to look in the file but it's obvious what's happening when I do! As you predicted, it relies on `dirname $0` to resolve the path to `ooffice`, which of course is wrong when invoked from the symbolic link in /usr/bin. Feel free to add this as a formal answer if you want acceptance for it. – ATG Jan 30 '15 at 20:28
  • I can offer a better answer if you can post the contents of `scalc`. My version of opensuse doesn't have that file. – Mark Plotnick Jan 30 '15 at 20:33
  • 1
    Do you have both `/usr/bin/soffice` and `/opt/openoffice4/program/soffice`? Do they have different contents? – Mark Plotnick Jan 30 '15 at 21:50

0 Answers0