Say we have bash file like so:
cd $(dirname "$0");
instead of executing the file directly, what happens when we read the file and then pipe it through bash? How does the "$0" get interpreted?
echo "$(cat <file>)" | bash
The reason I ask is because it seems unclear what the $0 would mean since the file is no longer necessarily running where it once was located. Perhaps somehow bash remembers where it was located and the $0 still refers to the original file location? Seems highly unlikely.