I want to run any program given as argument, through shell then want that shell left as interactive shell to use later.
#!/bin/bash
bash -i <<EOF
$@
exec <> /dev/tty
EOF
But it is not working with zsh
#!/bin/bash
zsh -i <<EOF
$@
exec <> /dev/tty
EOF
as well as if somebody know more improved way to do it please let me know.
Approach 1: bash, zsh and a few other shells read a file whose name is in the
ENV
environment variable after the usual rc files and before the interactive commands or the script to run. However bash only does this if invoked as sh, and zsh only does this if invoked as sh or ksh, which is rather limiting.Approach 2: make the shell read a different rc file, which sources the usual rc file and contains a call to the program you want to run. For example, for bash:
For zsh, the file has to be called
.zshrc
, you can only specify a different directory.At this point vim is opened.
shell is left for you to do other work. In my question the bash shell's STDIN was HEREDOC (<< EOF) so for so it not working for command who want to read from TTY. But after providing the command input from /dev/tty it start working.
I am not able to find how to correct warning
Why don't you simply start a new shell for interactive input?
I use this in a script to call gui programs from the shell, haven't tested it with zsh though