Background:
I'm trying make a function that runs commands on a set interval because I don't have access to a "watch" program. Simplified to it's most basic from, the function I'm trying to write is runit() { $1; }
.
What works:
This works fine and dandy when I pass it things that aren't aliases. For example, runit "ls -l"
works fine. I get the full output from the ls -l
command.
What doesn't work:
The problem starts when I pass it an alias. For example, setting alias ll="ls -l"
then calling runit "ll"
will result in -bash: ll: command not found
.
Things I have tried:
When I hard-code the alias runit() { ll; }
, it works fine and gives me what I expect.
I feel like I might be overlooking something, but I can't quite place my finger on it.
Why would hard-coding the alias work fine, but passing it into the function fail?
Is there a way to accomplish what I'm attempting to do?