* Re: Chatty little precompiler for _arguments
@ 1999-09-20 8:43 Sven Wischnowsky
1999-09-20 12:15 ` PATCH: was: " Sven Wischnowsky
1999-09-23 1:39 ` Tanaka Akira
0 siblings, 2 replies; 4+ messages in thread
From: Sven Wischnowsky @ 1999-09-20 8:43 UTC (permalink / raw)
To: zsh-workers
Bart Schaefer wrote:
> though it would be really useful if $param:q could emit quoting instead of
> backslashes.
I would be against this because its much less useful in cases where
you stuff together string from multiple parameters. However, in its
first life `:q' did that and we could use the doubled-flag convention
so that `${(qq)foo}' would emit stuff in single quotes. (Tripled for
double quotes?)
Bye
Sven
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 4+ messages in thread
* PATCH: was: Re: Chatty little precompiler for _arguments @ 1999-09-20 12:15 ` Sven Wischnowsky 1999-09-20 16:36 ` Bart Schaefer 0 siblings, 1 reply; 4+ messages in thread From: Sven Wischnowsky @ 1999-09-20 12:15 UTC (permalink / raw) To: zsh-workers I wrote: > Bart Schaefer wrote: > > > though it would be really useful if $param:q could emit quoting instead of > > backslashes. > > I would be against this because its much less useful in cases where > you stuff together string from multiple parameters. However, in its > first life `:q' did that and we could use the doubled-flag convention > so that `${(qq)foo}' would emit stuff in single quotes. (Tripled for > double quotes?) This does that. `${(qqq)foo}' looks a bit silly doesn't it? Bye Sven --- os/subst.c Mon Sep 20 13:53:20 1999 +++ Src/subst.c Mon Sep 20 14:05:41 1999 @@ -721,7 +721,7 @@ int flnum = 0; int sortit = 0, casind = 0; int casmod = 0; - int quotemod = 0, quoteerr = 0; + int quotemod = 0, quotetype = 0, quoteerr = 0; char *sep = NULL, *spsep = NULL; char *premul = NULL, *postmul = NULL, *preone = NULL, *postone = NULL; char *replstr = NULL; /* replacement string for /orig/repl */ @@ -826,7 +826,7 @@ break; case 'q': - quotemod++; + quotemod++, quotetype++; break; case 'Q': quotemod--; @@ -1617,6 +1617,8 @@ opts[PROMPTPERCENT] = opp; } if (quotemod) { + if (--quotetype > 2) + quotetype = 2; if (isarr) { char **ap; @@ -1624,10 +1626,23 @@ aval = arrdup(aval), copied = 1; ap = aval; - if (quotemod > 0) - for (; *ap; ap++) - *ap = bslashquote(*ap, NULL, 0); - else { + if (quotemod > 0) { + if (quotetype) { + int sl; + char *tmp; + + for (; *ap; ap++) { + tmp = bslashquote(*ap, NULL, quotetype); + sl = strlen(tmp); + *ap = (char *) zhalloc(sl + 3); + strcpy((*ap) + 1, tmp); + ap[0][0] = ap[0][sl + 1] = (quotetype == 1 ? '\'' : '"'); + ap[0][sl + 2] = '\0'; + } + } else + for (; *ap; ap++) + *ap = bslashquote(*ap, NULL, 0); + } else { int one = noerrs, oef = errflag, haserr = 0; if (!quoteerr) @@ -1648,9 +1663,20 @@ } else { if (!copied) val = dupstring(val), copied = 1; - if (quotemod > 0) - val = bslashquote(val, NULL, 0); - else { + if (quotemod > 0) { + if (quotetype) { + int sl; + char *tmp; + + tmp = bslashquote(val, NULL, quotetype); + sl = strlen(tmp); + val = (char *) zhalloc(sl + 3); + strcpy(val + 1, tmp); + val[0] = val[sl + 1] = (quotetype == 1 ? '\'' : '"'); + val[sl + 2] = '\0'; + } else + val = bslashquote(val, NULL, 0); + } else { int one = noerrs, oef = errflag, haserr; if (!quoteerr) diff -u od/Zsh/expn.yo Doc/Zsh/expn.yo --- od/Zsh/expn.yo Mon Sep 20 13:06:32 1999 +++ Doc/Zsh/expn.yo Mon Sep 20 14:14:20 1999 @@ -582,7 +582,9 @@ that result from field splitting. ) item(tt(q))( -Quote the resulting words with backslashes. +Quote the resulting words with backslashes. If this flag is given +twice, the resulting words are quoted in single quotes and if it is +given three times, the words are quoted in double quotes. ) item(tt(Q))( Remove one level of quotes from the resulting words. -- Sven Wischnowsky wischnow@informatik.hu-berlin.de ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Chatty little precompiler for _arguments 1999-09-20 12:15 ` PATCH: was: " Sven Wischnowsky @ 1999-09-20 16:36 ` Bart Schaefer 0 siblings, 0 replies; 4+ messages in thread From: Bart Schaefer @ 1999-09-20 16:36 UTC (permalink / raw) To: Sven Wischnowsky, zsh-workers On Sep 20, 10:43am, Sven Wischnowsky wrote: } Subject: Re: Chatty little precompiler for _arguments } } Bart Schaefer wrote: } } > though it would be really useful if $param:q could emit quoting instead of } > backslashes. } } I would be against this because its much less useful in cases where } you stuff together string from multiple parameters. I'm not sure what you're getting at, there. With 7951 applied, compare: print -R ${(q):-"$histchars $WORDCHARS $SPROMPT $TIMEFMT"} print -R ${(qq):-"$histchars $WORDCHARS $SPROMPT $TIMEFMT"} print -R ${(qqq):-"$histchars $WORDCHARS $SPROMPT $TIMEFMT"} On Sep 20, 2:15pm, Sven Wischnowsky wrote: } Subject: PATCH: was: Re: Chatty little precompiler for _arguments } } This does that. `${(qqq)foo}' looks a bit silly doesn't it? The man who wrote ${(@)^${(@)${(@)${(@M)${(@ps:\n:j:\n:)${(@)${(@M)${(@f)$(${~words[1]} --help 2>&1)//\[--/ --}:#[ ]#-*}//,/ }}:#[ ]#--*}#*--}%%[, ]*}:#} wants to talk about "looks a bit silly"? -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Chatty little precompiler for _arguments 1999-09-20 8:43 Chatty little precompiler for _arguments Sven Wischnowsky 1999-09-20 12:15 ` PATCH: was: " Sven Wischnowsky @ 1999-09-23 1:39 ` Tanaka Akira 1 sibling, 0 replies; 4+ messages in thread From: Tanaka Akira @ 1999-09-23 1:39 UTC (permalink / raw) To: zsh-workers In article <199909200843.KAA06289@beta.informatik.hu-berlin.de>, Sven Wischnowsky <wischnow@informatik.hu-berlin.de> writes: > I would be against this because its much less useful in cases where > you stuff together string from multiple parameters. However, in its > first life `:q' did that and we could use the doubled-flag convention > so that `${(qq)foo}' would emit stuff in single quotes. (Tripled for > double quotes?) I found a problem about quoting. Z(2):akr@is27e1u11% Src/zsh -f is27e1u11% a=$'\n\n\n\n\n\n' is27e1u11% print -lr - ${(q)a} zsh: segmentation fault (core dumped) Src/zsh -f Also I suppose that `${(qqqq)foo}' should quote foo in $'...' style. # I really want this because I frequently use dangeraous characters # such as NUL. -- Tanaka Akira ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1999-09-23 1:51 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 1999-09-20 8:43 Chatty little precompiler for _arguments Sven Wischnowsky 1999-09-20 12:15 ` PATCH: was: " Sven Wischnowsky 1999-09-20 16:36 ` Bart Schaefer 1999-09-23 1:39 ` Tanaka Akira
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).