Consider a script pass_command
ls | "$@"
It accepts named commands as arguments
pass_command sort
#prints files sorted
Which is good enough for all practical purposes. I'm curious though, Is there a mechanism that lets me pass compound commands? Something like
pass_command (sort | uniq) #Forgive the silly example.
Edit: A more complicated example that motivated this question.
until who | grep mary
do
sleep 60
until
Signals mary logging on. I wanted to generalize this to signal some event. The intuitive idea was this:
#watchfor
until "$@"
do
sleep 60
done
And then you would call it as
watchfor (who | grep mary)
That was the idea. You can give the argument a name, and the above works fine. It just made me think of this.
I suppose I was trying to understand the most idiomatic way of hiding the signaling command.