zsh-workers
 help / color / mirror / code / Atom feed
From: Greg Klanderman <gak@klanderman.net>
To: zsh-workers@sunsite.dk
Subject: Re: treatment of empty strings - why is this not a bug?
Date: Fri, 16 Jan 2009 12:35:45 -0500	[thread overview]
Message-ID: <m38wpbw3v2.fsf@klanderman.net> (raw)
In-Reply-To: <090115201912.ZM20275@torch.brasslantern.com> (Bart Schaefer's message of "Thu, 15 Jan 2009 20:19:12 -0800")

>>>>> Bart Schaefer <schaefer@brasslantern.com> writes:

> I was hoping to just let this thread go by, but maybe I'm the only one
> still on list who's been around long enough to have an inkling of what
> is going on here.

Hi Bart, thank you for responding to this question.  I hope you and/or
Peter will entertain one more round of this thread and answer my final
two questions, then I'll happily drop it if you wish.

> Paul Falstad (original author of zsh) made a conscious decision that
> a non-empty string, even one containing some or only characters that
> appear in $IFS, was a significant item of data and should remain in
> the expansion of $@.  However, he was unwilling to deviate from the
> standard semantics of $@ to the point of treating empty strings as
> significant.

I almost think it's worse this way - you read the docs and think "Oh
great, I don't have to worry about putting all those crazy double
quotes around everything anymore to preserve my array elements",
however, you in fact do still need all those double quotes.

> Too many programs that deal with file names, for example,
> would begin spewing errors if they received empty strings in their
> argument lists when called as e.g. ls -l $@.

I don't understand how empty strings get into arrays unless one
explicitly puts them there.. and if one explicitly puts them there,
then presumably they don't want them randomly dropped.

The best reason I can come up with for this semantics is having code
like this continue to work:

    foo_arg=""
    if [[ ... ]] ; then
      foo_arg="-bar"
    fi
    foo $foo_arg

However, now that our shell has arrays, that should really be written
as:

    foo_arg=()
    if [[ ... ]] ; then
      foo_arg=("-bar")
    fi
    foo $foo_arg

and so I see no remaining need for dropping empty strings.

> The point is to be minimally surprising to the person who just doesn't
> want to think very hard about array and $IFS semantics, not to be
> entirely logically consistent to someone who analyzes the behavior in
> detail.  If you're enough of a geek to care, you're also enough of a
> geek to figure out a workaround.

Sure, I can keep using double quotes, but I don't want to given how
close zsh is to DTRT and not needing them.

You and Peter seem to be in charge here - do you both still agree that
dropping empty strings is a desirable default?

Would you guys be OK with adding an option to inhibit this?

thank you,
Greg


  reply	other threads:[~2009-01-16 17:36 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-13  7:32 Greg Klanderman
2009-01-13 19:24 ` Peter Stephenson
2009-01-13 22:08   ` Peter Stephenson
2009-01-15 20:11     ` Greg Klanderman
2009-01-15 20:29       ` Peter Stephenson
2009-01-16 10:02         ` Peter Stephenson
2009-01-15 20:28     ` Greg Klanderman
2009-01-15 20:34       ` Peter Stephenson
2009-01-16  4:19 ` Bart Schaefer
2009-01-16 17:35   ` Greg Klanderman [this message]
2009-01-16 17:55     ` Peter Stephenson
2009-01-16 19:40       ` Greg Klanderman
2009-01-16 23:26         ` Richard Hartmann
2009-01-17  3:45         ` Bart Schaefer
2009-01-17  3:35     ` Bart Schaefer
2009-01-17  5:31       ` Greg Klanderman
2009-01-17 17:53         ` Peter Stephenson
2009-05-17  4:55 PATCH: make PROMPT_SP end-of-line marker configurable Greg Klanderman
2009-05-17 17:27 ` Peter Stephenson
2009-05-17 18:04   ` Greg Klanderman
2009-05-17 19:23     ` Peter Stephenson
2009-05-18  1:00       ` Greg Klanderman
2009-05-18 18:27       ` Greg Klanderman
     [not found] <gak@klanderman.net>
2009-06-26 20:40 ` bug in ztrftime(): '%e' and '%f' specifiers swapped Greg Klanderman
2009-06-26 21:23   ` Peter Stephenson
2009-06-26 21:57     ` Greg Klanderman
2010-02-05 17:01 have '&' automatically disown? Greg Klanderman
2010-02-05 17:33 ` Peter Stephenson
2010-02-05 17:36   ` Peter Stephenson
2010-02-06  3:26     ` Greg Klanderman
2010-02-07 18:20       ` Peter Stephenson
2010-02-07 21:06         ` Greg Klanderman
2010-02-07 21:34           ` Peter Stephenson
2010-02-07 22:36             ` Bart Schaefer
2010-09-02 14:57               ` Greg Klanderman
2010-09-05 19:11                 ` Bart Schaefer
2010-09-06  1:50                   ` Greg Klanderman
2010-02-07 21:59           ` Mikael Magnusson

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=m38wpbw3v2.fsf@klanderman.net \
    --to=gak@klanderman.net \
    --cc=zsh-workers@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).