zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: new parameter flag?
Date: Mon, 30 Aug 1999 11:39:27 +0200 (MET DST)	[thread overview]
Message-ID: <199908300939.LAA20676@beta.informatik.hu-berlin.de> (raw)


Dunno if you like this...

This adds the `%' flag to parameter expansion. It makes the result of
the expansion undergo prompt expansion. For things like

  POSTEDIT="${(%):-%b}"
  day="${${(%):-%W}[1,2]}"

Maybe we should finally implement the non-forking form of `$(...)'
instead...

Bye
 Sven

--- os/subst.c	Sun Aug 29 20:00:19 1999
+++ Src/subst.c	Sun Aug 29 19:51:01 1999
@@ -730,6 +730,7 @@
     int arrasg = 0;
     int eval = 0;
     int aspar = 0;
+    int presc = 0;
     int nojoin = 0;
     char inbrace = 0;		/* != 0 means ${...}, otherwise $... */
     char hkeys = 0;
@@ -934,6 +935,10 @@
 		    wantt = 1;
 		    break;
 
+		case '%':
+		    presc = 1;
+		    break;
+
 		default:
 		  flagerr:
 		    zerr("error in flags", NULL, 0);
@@ -1567,6 +1572,28 @@
 		makelowercase(&val);
 	    else
 		makecapitals(&val);
+	}
+    }
+    if (presc) {
+	int len;
+
+	if (isarr) {
+	    char **ap;
+
+	    if (!copied)
+		aval = arrdup(aval), copied = 1;
+	    ap = aval;
+	    for (; *ap; ap++) {
+		unmetafy(*ap, &len);
+		*ap = unmetafy(promptexpand(metafy(*ap, len, META_NOALLOC),
+					    0, NULL, NULL), &len);
+	    }
+	} else {
+	    if (!copied)
+		val = dupstring(val), copied = 1;
+	    unmetafy(val, &len);
+	    val = unmetafy(promptexpand(metafy(val, len, META_NOALLOC),
+					0, NULL, NULL), &len);
 	}
     }
     if (quotemod) {
diff -u od/Zsh/expn.yo Doc/Zsh/expn.yo
--- od/Zsh/expn.yo	Sun Aug 29 20:00:46 1999
+++ Doc/Zsh/expn.yo	Sun Aug 29 19:58:10 1999
@@ -587,6 +587,10 @@
 item(tt(Q))(
 Remove one level of quotes from the resulting words.
 )
+item(tt(%))(
+Expand all tt(%) escapes in the resulting words in the same way as in
+prompts (see noderef(Prompt Expansion)).
+)
 item(tt(X))(
 With this flag parsing errors occuring with the tt(Q) flag or the
 pattern matching forms such as `tt(${)var(name)tt(#)var(pattern)tt(})' 

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


             reply	other threads:[~1999-08-30  9:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-08-30  9:39 Sven Wischnowsky [this message]
1999-08-31  9:29 ` Zefram
1999-08-31 11:45 Sven Wischnowsky
1999-08-31 12:25 ` Zefram
1999-08-31 12:43 Sven Wischnowsky
1999-09-01  8:35 ` Peter Stephenson
1999-09-01  9:33 Sven Wischnowsky

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=199908300939.LAA20676@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@sunsite.auc.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).