Article 51G4N How to write new custom 'binaries'?

How to write new custom 'binaries'?

by
SomeLinuxUser
from LinuxQuestions.org on (#51G4N)
Newbie here, please forgive any abuse of terminology.

Suppose I want to write an open command-line utility, similar to what's available on MacOS, which will open a target file using the pre-specified program (zathura for pdfs, vim for .cpp files etc), preferably via a lookup from a .openrc config or similar. I wrote a post on here a while back looking for program which does this, and the users suggested writing one myself if I wanted it. Thought it was a good test case for how this stuff works.

I understand that files can be made executable with a chmod +x, so presumably one can just write a shell script which does something like this.

If you want a binary to be place in /usr/local/bin, would you write it in C, compile it and just put the output in there? I assume you don't place shell scripts in there?

Side question: How would you write such a binary which is capable of accepting an extra argument such as "open foo.pdf" -> run open with some variable saved as "foo.pdf"?latest?d=yIl2AUoC8zA latest?i=WQ8Gb3i_1rQ:2VqoUqOKuXU:F7zBnMy latest?i=WQ8Gb3i_1rQ:2VqoUqOKuXU:V_sGLiP latest?d=qj6IDK7rITs latest?i=WQ8Gb3i_1rQ:2VqoUqOKuXU:gIN9vFwWQ8Gb3i_1rQ
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments