Symbolic link with option

lnoptionssymlink

Is it possible to create a symbolic link to an executable that executes it with a certain option/argument?

I know a workaround would be to create a bash script in one of the PATH directories but can I achieve it somehow with a symbolic link?

EDIT: Thanks for the answers, in my case an alias wouldn't do the job because i'm looking for a way to start matlab from dmenu and at least on arch matlab is only invokable from a terminal at first. Since dmenu does not consider aliases it wouldn't work .. i should have made my problem more clear.

Best Answer

No, a symbolic link is a type of file that references the path of another file.

Now, if you do:

ln -s /bin/cat foo

And invoke foo as:

$ ./foo -A /proc/self/cmdline
./foo^@-A^@/proc/self/cmdline^@

You'll notice that the first argument that cat/foo received was ./foo and not cat. So, in a way, through that symlink, we've had cat receive a different first argument. That's probably not what you had in mind for your first argument though.

Using a shell script wrapper is the typical way to address it. You don't need to use bash for that though. Your system's standard sh will be more than enough for that:

#! /bin/sh -
exec /path/to/my/executable --extra-option "$@"

Other options include defining an alias or function in your ~/.bashrc/~/.zshrc... for it