Score:0

Aliases sourced from file are not available when run in subshell

cn flag

I am trying to execute a bash command like so.

/bin/bash -c "shopt -s expand_aliases; source things-with-aliases; alias; aliasname"

I know that -i brings in my own .bash_aliases and I don't need it, but adding it doesn't make a difference. aliases defined in my .bash_aliases are properly expanded when I use -i, but not ones that I further source.

This is not a duplicate of https://unix.stackexchange.com/questions/144932/why-are-aliases-missing-inside-of-bash-command when the alias command is run in the subshell it prints the aliases, but in the next step it refuses to expand the alias.

cn flag
For the record, I tried substituting functions for these aliases, but it took me forever to realize that the functions need to be exported as well in order to make it to subshells. https://unix.stackexchange.com/questions/65751/how-to-get-functions-propagated-to-subshell solved my problem
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.