I want to learn to create a wrapper around a program in linux. How does one do this? A tutorial reference web-page/link or example will do. To clarify what I want to learn, I will explain with an example.
I use vim for editing text files. And use rcs as my simple revision control system. rcs allows you to check-in and checkout-files. I would like to create a warpper program named vir which when I type in the shell as:
$ vir temp.txt
will load the file temp.txt into rcs with ci -u temp.txt
and then allows me to edit the file using vim.
When I get out and go back in, It will need to check out the file first, using ci -u temp.txt
and allow me to edit the file as one normally does with vim, and then when I save and exit, it should check-in the file using co -u temp.txt
and as part of that I should be able to add a version control comment.
Basically, all I want to be doing on the command line is:
$ vir temp.txt
as one would with vim. And the wrapper should take care of the version control for me.
I have a wrapper to enhance the ping command (using zsh) it could, maybe help you:
What it hides the local ping using a function called "ping", so if your script has precedence on your path it will find at first the function ping. Then inside the script I define an internal variable called ping that points out to the real ping command:
You can also notice that the args are stored in one array.