From https://unix.stackexchange.com/a/276611/674
When
bashis run with-c, it is considered a non-interactive shell, and it does not read~/.bashrc, unless is-ispecified. So,$ type cp cp is aliased to ‘cp -i’ # Defined in ~/.bashrc $ cp .file1 file2 cp: overwrite ‘file2’? n $ bash -c "cp .file1 file2" # Existing file is overwritten without confirmation! $ bash -c -i "cp .file1 file2" cp: overwrite ‘file2’? n
Is the shell created by bash -i -c <command> interactive or non-interactive?
Such a shell doesn't accept a command from stdin, does it? So it is not interactive, is it?
Such a shell reads ~/.bashrc, so it can't be non-interactive, can it?
bash -i -c, if it is an interactive shell, can it accept a command from stdin? – Tim Apr 18 '16 at 16:51bash -care still attached to the current terminal. Consider this simple "command interpreter", which will execute the commandlsfrom stdin despite running as a non-interactive shell:echo ls | bash -c 'read p; eval "$p"'– Guido Apr 18 '16 at 17:08echo ls | bash -c 'read p; eval "$p"'accepts input to commandreadfrom stdin, and it doesn't accept a command from stdin. – Tim Apr 18 '16 at 18:04