Check this script:
#!/bin/bash if true;then alias WeirdTest='uptime';shopt -s expand_aliases WeirdTest fi WeirdTest
The first time
WeirdTest is executed it says "command not found".
This is a limitation of bash. Quoting the manual:
Bash expands aliases when it reads a command. A command, in this sense, consists of complete commands (the whole
A possible workaround is to define a function:
If you wanted to use an alias so that it could call an external command by the same name, you can do that with a function by adding