0

The context

I've downloaded scilab-6.1.0.bin.linux-x86_64.tar.gz from the official website of "Scilab" because I want to be able to use the provided tools.

Within the bin directory of the downloaded files, I've the following files

$ ls -l | cut -d ' ' -f 5-

1713591 Feb 25 05:27 modelicac
2057719 Feb 25 05:27 modelicat
  44563 Feb 25 05:27 scilab
      6 Feb 25 05:27 scilab-adv-cli -> scilab
  24741 Feb 25 05:27 scilab-bin
      6 Feb 25 05:27 scilab-cli -> scilab
  20725 Feb 25 05:27 scilab-cli-bin
  44563 Feb 25 05:27 scinotes
  44563 Feb 25 05:27 xcos
 675942 Feb 25 05:27 XML2Modelica

$ test -L scilab-adv-cli && test -L scilab-cli && echo $?
0

As we can see, both scilab-cli and scilab-adv-cli are symbolic links to scilab. Executing scilab-cli, scilab-adv-cli and scilab yields to different results (see gif below)

enter image description here

The question

Isn't a symbolic link (A) , which points to an executable (B), be supposed to execute (B)?

In the scenario presented above, scilab-cli and scilab-adv-cli would be (A) and scilab would be (B).

3

Running a symlink which points to an executable does indeed run the executable, but there is one important difference: the first argument given to the new process, which (in this case) stores the command given, gives the name of the symlink, not the name of the target executable. This allows programs to implement different behaviours depending on how they’re called.

One common instance which is likely to be installed on your system is apropos: it’s typically (on Linux systems at least) a symlink to whatis, but the two commands behave differently.

In your case, when scilab is run as scilab-cli, it presents its text-mode interface; when it’s run as scilab (as happens with your realpath approach), it starts its GUI.

1
  • I didn't think about that. A good way of explaining this is through a single bash script which contains a conditional that compares the value of $0 with the name of a regular file and the names of its corresponding symbolic links. – gfe May 5 '20 at 13:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.