OK, here's the deal. The command name (program name) part of any command line typed at the dot prompt is folded to upper case (as in AMOS), simplifying the parsing logic which tries to determine whether the command is a LIT, RUN, command file, etc.
But at some some point in the distant past, we stopped folding the initial launch command line to allow passing of commands that referenced native files or other case-sensitive stuff. So, when "tw.do" was passed as an initial command on the launch command line, A-Shell was failing to recognize it as a DO file, so it wasn't getting the benefit of DO-file pre-processing (which is where $ variables get expanded).
Now that doesn't quite jibe with your claim that it works from the shell prompt, but perhaps you can go back and try it again, using TW.DO instead of tw.do to see if it then works in all cases.
I've inserted a fix into 5.1.1167 to make the test case insensitive, but I'm not sure if: a) it is a complete fix, or b) it will be worth it to you (or me) to update ashell 5.0 when the workaround is relatively simple.
So, let me know what you think.