bash trick - prefixing a command?

Ezra Nugroho enugroho at spikesource.com
Tue Oct 25 17:23:30 UTC 2005


On Tue, 2005-10-25 at 13:17 -0400, Dr. Michael J. Chudobiak wrote:
> Terry Polzin wrote:
> >> I want to do some shell trickery so that when a user enters a command like:
> >>
> >> ls -l
> >>
> >> the command is forwarded to another program as an argument. That is,
> >> what actually gets executed is:
> >>
> >> myprog "ls -l"
> >>
> > I think what yo want to do would be a command alias.  Generally, these are  
> > setup in either the /etc/profile or in the individual users .bash_profile 
> 
> 
> No, I don't think an alias would work - the argument isn't known ahead 
> of time, so you can't define an alias.


That's right. I think creating another shell on the top of bash is the
easiest way to go. The shell doesn't have to be a complicated full blown
one, it can be just a thin layer above bash that waits for an input,
takes the input string, evaluate it, and pass it to appropriate program.
You can do it with any languages, including perl, and probably with
bash!


Ezra





More information about the fedora-list mailing list