I want to run an alias inside a
bash -c construct.
bash manual says:
Aliases are not expanded when the shell is not interactive, unless the
expand_aliasesshell option is set using
In this example, why is the alias
hi not found when setting
% bash -O expand_aliases -c "alias hi='echo hello'; alias; shopt expand_aliases; hi" alias hi='echo hello' expand_aliases on bash: hi: command not found
GNU bash, version 5.0.0(1)-release (x86_64-pc-linux-gnu).
Context: I want to be able to run an alias at idle priority, eg a script containing:
#!/bin/bash exec chrt -i 0 nice -n 19 ionice -c 3 bash -c ". ~/.config/bash/aliases; shopt -s expand_aliases; $(shell-quote "$@")"
I want to avoid using
bash -i as I don't want my
.bashrc to be read.