zsh-users
 help / color / mirror / code / Atom feed
From: "Tim K. (Gmane)" <tk-gmane+at@idpax.com>
To: zsh-users@sunsite.dk
Subject: Re: have zsh invoke a command/script but not exit
Date: Tue, 31 May 2005 07:28:12 -0700	[thread overview]
Message-ID: <d7hs4k$gtm$1@sea.gmane.org> (raw)
In-Reply-To: <1050530180644.ZM30338@candle.brasslantern.com>

Thanks for your reply. I have to go learn about the advanced (at least 
to me) things you suggested below.

Tim



Bart Schaefer wrote:

>On May 30,  8:51am, Tim K. (Gmane) wrote:
>}
>} Is it possible to start zsh and invoke some other command/script but 
>} upon command completion to return to interactive mode rather than exit 
>} from zsh?
>
>After the startup files are finished, zsh reads commands from exactly
>one of four places:  The argument of the -c option, the current terminal,
>the standard input, or a script file.
>
>A script file is assumed if zsh has arguments but no options specifying
>one of the other sources.  The documentation implies that -s forces zsh
>to read from stdin, but in fact the -s option only determines whether
>any further arguments are taken as the name of a script file; when both
>-i and -s appear, -i takes precedence to force input from the terminal.
>The -c option overrides both -i and -s, except that the .zshrc file is
>read when both -i and -c appear.
>
>The prompt is printed only in interactive mode, and you can't change the
>value of that option after startup, so it's impossible to be prompted
>after a command has been read from anywhere other than the terminal
>(unless you run your own input loop e.g. using "vared").
>
>} The only way I can think off is to put some hack in my .zshrc where if 
>} some env variable is set it will run that command at the end of my 
>} .zshrc file
>
>How about using $@ instead of an environment variable?
>
>    if [[ $1 == eval ]]
>    then
>    	"$@"
>	set --
>    fi
>
>Then you run this as
>
>    zsh -is eval 'ls *.txt'
>
>You could even skip the requirement that "eval" be the first word:
>
>    if (( $# ))
>    then
>    	eval "$@"
>	set --
>    fi
>
>However, using "eval" as a keyword there means that you can still use
>zsh -is with other argument strings without treating them as commands.
>
>I like this because it lends itself to becoming an alias.
>
>    alias zshi='zsh -is eval '
>
>(The trailing space is for completion purposes.)
>
>Hmm.  Depending on how you expect to use that, you might want to change
>the .zshrc part to:
>
>    if [[ $1 == eval ]]
>    then
>    	"${(q)@}"
>	set --
>    fi
>
>You can see the difference if you run:
>
>    zshi echo foo \; echo bar
>    zshi 'echo foo ; echo bar'
>
>Try each of those both with the (q) and without, and pick the way that
>makes the most sense to you.
>
>  
>


      reply	other threads:[~2005-05-31 14:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-30 15:51 Tim K. (Gmane)
2005-05-30 18:06 ` Bart Schaefer
2005-05-31 14:28   ` Tim K. (Gmane) [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='d7hs4k$gtm$1@sea.gmane.org' \
    --to=tk-gmane+at@idpax.com \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).