Note this is sourced, so this is not a shell script.
I am not asking for how to enable alias in noninteractive shell. I did this: shopt -s expand_aliases.
The Bash version is 5.1.4.
How to recreate:
Create a file named "p":
linky(){
comdll="cat"
shopt -s expand_aliases
alias modavar="$comdll"
echo "$argin" | modavar #| getlinks "$argin" | sort -u
}
Then run
echo "source p ; linky https://duckduckgo.com" | bash --norc
Expected output:
https://duckduckgo.com
Actual output:
p: line 5: modavar: command not found
When I run this once it give me
linky(){ alias jkl=echo\ hel; jkl; }
linky
bash: jkl: command not found
But if I do this,
linky(){ alias jkl=echo\ hel; jkl; }
linky
linky(){ alias jkl=echo\ hel; jkl; }
linky
It gives me
hel
What is happening?