zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@sunsite.dk
Subject: Re: Execute a Command in PS1 w/o Disturbing Previous Return Value?
Date: Fri, 13 Aug 2004 10:32:32 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.61.0408130204340.15905@toltec.zanshin.com> (raw)
In-Reply-To: <D0F204E0-ECD9-11D8-83BE-000502631FBD@louisville.edu>

On Thu, 12 Aug 2004, Aaron Davies wrote:

> I'm trying to write a prompt that will do two things: include a file 
> frequently re-downloaded from the web, and indicate the return status of 
> the previous command. The problem is, if I cat out the file, it returns 
> 0, overwriting the return status read by the %(0?%) directive

This should probably be considered a bug.

> What can I do about this?

In addition to Philippe's suggestion of using precmd so that $? is saved
and restored for you by the shell -- which is what should be happening 
during command substitutions in prompt expansion, but isn't -- a simple
alternative is to use $(<...) instead of `cat ...`.

You can also use $'...' instead of `echo '...'`

export PS1='$(</tmp/temperature)'" %m%~ %(0?."\
$'%{\e[1;32m%}:)%{\e[0m%}.%{\e[1;31m%}:(%{\e[0m%}'") %# "


  parent reply	other threads:[~2004-08-13 17:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-13  3:35 Aaron Davies
2004-08-13  4:52 ` Philippe Troin
2004-08-13 17:32 ` Bart Schaefer [this message]
2004-08-14 16:07   ` Aaron Davies
2004-08-15 15:17     ` Phil!Gregory

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=Pine.LNX.4.61.0408130204340.15905@toltec.zanshin.com \
    --to=schaefer@brasslantern.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).