Imagine you have a silly script test.sh to which arguments are passed that would look like this:
bash test.sh arg1 arg2 arg3
with test.sh being a silly script that displays its command line:
#!/bin/bash
echo "$0 $*"
I would like to do the same using bash heredoc << to feed the script to bash. So I tried this :
bash <<'EOF' -- arg1 arg2 arg3
echo "$0 $*"
EOF
But it fails with error
bash: arg1: No such file or directory
Any idea ?