Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 2
    This question is similar to: Non-interactive shell expand alias. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. Commented May 26 at 5:40
  • @muru; While it explained why this is happening, it didn't clarify quite well on what needs to be done. If you don't mind, I may post one as answer to put together a few answers posted there to make it a complete q and a pair. Not sure if this thread should be removed altogehter but I guess I'll leave it up to someone else. Commented May 26 at 5:59
  • It's not entirely clear to me how you finally intend to use it. If you're actually writing an entire script that will individually test each alias by executing it in the script itself, then shopt -s expand_aliases in the script might be enough. But if the script is executing bash -c for each alias, then see the invocation in the answer below (though you might get away with bash -O expand_aliases -lc 'some-alias' depending on your environment) Commented May 26 at 9:06
  • You define an alias called alias_test but try to call test-alias. It is unclear what test-alias is. Commented May 26 at 10:35
  • @Kusalananda; Right, that was a typo, thanks for picking that up! @muru; -O option did the elegant trick for me! Thanks for the advice. Commented May 27 at 10:29