I have the following bash script, it is running in a file named some_file.sh, the contents look like
sudo -i -u $USER bash << EOF
func(){
echo $1
}
func 'Test message for channel'
EOF
This returns nothing in the argument for the function even though the function is invoked with an argument, what am I doing wrong?
To invoke it I do
bash some_file.sh
$1is already expanded before sudo is invoked. If you would call it asbash some_file.sh FOO, you would see the effect of the expansion better.