* Buggy zed function
@ 2006-01-10 16:10 Vincent Lefevre
2006-01-10 16:47 ` Peter Stephenson
0 siblings, 1 reply; 2+ messages in thread
From: Vincent Lefevre @ 2006-01-10 16:10 UTC (permalink / raw)
To: zsh-workers
The zed function is buggy. After typing:
fctest() {
cat <<EOF
foo
bar
EOF
}
I got the following (with zsh 4.2.6 and zsh 4.3.0-dev-2). Note: in zed,
I immediately type Ctrl-J to accept.
dixsept% which fctest
fctest () {
cat <<< 'foo
bar'
}
dixsept% fctest
foo
bar
dixsept% autoload zed
dixsept% zed -f fctest
fctest () {
cat <<< 'foo
bar'
}
dixsept% which fctest
fctest () {
cat <<< "'foo
bar'"
}
dixsept% fctest
foo
bar
dixsept% zed -f fctest
fctest () {
cat <<< "'foo
bar'"
}
dixsept% which fctest
fctest () {
cat <<< ""'foo
bar'""
}
dixsept% fctest
'foo
bar'
--
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / SPACES project at LORIA
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Buggy zed function
2006-01-10 16:10 Buggy zed function Vincent Lefevre
@ 2006-01-10 16:47 ` Peter Stephenson
0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2006-01-10 16:47 UTC (permalink / raw)
To: zsh-workers
Vincent Lefevre <vincent@vinc17.org> wrote:
> dixsept% which fctest
> fctest () {
> cat <<< 'foo
> bar'
> }
> dixsept% fctest
> foo
> bar
> dixsept% autoload zed
> dixsept% zed -f fctest
> fctest () {
> cat <<< 'foo
> bar'
> }
> dixsept% which fctest
> fctest () {
> cat <<< "'foo
> bar'"
> }
It's not zed, you can see it just by entering
fctest () {
cat <<< 'foo
bar'
}
which fctest
The argument from a here string is output in a slightly strange way. The
only reason I can see is for just the case you have, when it's been input
as a here document. In that case it's a raw string and needs quoting. I
think that's OK; it's the other case that needs changing. As far as I
know, we never get there directly from a here document since that shouldn't
produce tokens, so it should be good enough just to output that as a normal
string without the extra layer of quoting. However, there may be a case
I've missed...
Index: Src/text.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/text.c,v
retrieving revision 1.15
diff -u -r1.15 text.c
--- Src/text.c 12 Apr 2005 15:11:12 -0000 1.15
+++ Src/text.c 10 Jan 2006 16:38:16 -0000
@@ -798,16 +798,17 @@
taddstr(fstr[f->type]);
if (f->type != REDIR_MERGEIN && f->type != REDIR_MERGEOUT)
taddchr(' ');
- if (f->type == REDIR_HERESTR) {
- if (has_token(f->name)) {
- taddchr('\"');
- taddstr(bslashquote(f->name, NULL, 2));
- taddchr('\"');
- } else {
- taddchr('\'');
- taddstr(bslashquote(f->name, NULL, 1));
- taddchr('\'');
- }
+ if (f->type == REDIR_HERESTR && !has_token(f->name)) {
+ /*
+ * Strings that came from here-documents are converted
+ * to here strings without quotation, so add that
+ * now. If tokens are already present taddstr()
+ * will do the right thing (anyway, adding more
+ * quotes certainly isn't right in that case).
+ */
+ taddchr('\'');
+ taddstr(bslashquote(f->name, NULL, 1));
+ taddchr('\'');
} else
taddstr(f->name);
taddchr(' ');
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
Your mail client is unable to display the latest news from CSR. To access our news copy this link into a web browser: http://www.csr.com/email_sig.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-01-10 16:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-10 16:10 Buggy zed function Vincent Lefevre
2006-01-10 16:47 ` Peter Stephenson
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).