bash < script.bash vs. bash script.bash

Hi

what's the difference? It's exactly the same?!

bash < script.bash vs. bash script.bash

> head -n1 vcs-1.12.3.bash 
#!/usr/bin/env bash

> bash < vcs-1.12.3.bash 
Video Contact Sheet *NIX v1.12.3, (c) 2007-2011 Toni Corvera
mplayer and/or ffmpeg are required!
Required program convert not found!
Required program montage not found!
Required program identify not found!

> bash vcs-1.12.3.bash 
Video Contact Sheet *NIX v1.12.3, (c) 2007-2011 Toni Corvera
mplayer and/or ffmpeg are required!
Required program convert not found!
Required program montage not found!
Required program identify not found!

hi,

Does it really matters?
No wise bash coder will execute a bash script in any of this way as there is a shebang that tells the kernel to use bash as the command interpreter.

Yes. At least for education purpose

I know that, but I am interested because never heard from "bash < script" invoking method.

It's not exactly the same.

Try reading from standard input in a script run with bash < script.bash -- you can't. Or at least, the results aren't what you'd expect! Reading from standard input, when standard input has been redirected into bash as a script file, would read a line of code from the script, not the terminal!

Some differences that come to mind ...
Consider the following:

# cat <<\! > -q
> printf '$0 => %s\n' "$0"
> !
# bash < -q   # strange filename, the redirection will work
$0 => bash
# bash -q     # strange filename, this invocation may not work
bash: -q: invalid option
Usage:  bash [GNU long option] [option] ...
        bash [GNU long option] [option] script-file ...
GNU long options:
        --debug
        --debugger
        --dump-po-strings
        --dump-strings
        --help
        --init-file
        --login
        --noediting
        --noprofile
        --norc
        --posix
        --protected
        --rcfile
        --rpm-requires
        --restricted
        --verbose
        --version
Shell options:
        -irsD or -c command or -O shopt_option          (invocation only)
        -abefhkmnptuvxBCHP or -o option
# bash -- -q  # this one will work, some builtin variables will have a different values 
$0 => -q

And to illustrate what Corona688 has pointed out:

# cat <<\! > a_script
> read
> printf 'REPLY => %s\n' "$REPLY"
> !
# bash a_script
ok
REPLY => ok
# bash < a_script
#