I am writing a bash script that runs each of its arguments as a command. This works for commands in my
PATH, but not for aliases. I can directly call an alias in the script, but I can't call an alias that has been passed as an argument.
The problem (I assume) is that aliases are expanded before variables. Is there a way to run aliases from a variable?
#!/bin/bash # File: runall shopt -s expand_aliases source ~/.aliases while (( "$#" )); do $1 shift done
runall "echo test" works, but
runall "myalias" gives
runall: line 8: myalias: command not found