zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers@zsh.org
Subject: Re: [BUG] zf_ln complains about the wrong argument
Date: Mon, 23 Aug 2021 09:33:21 +0100 (BST)	[thread overview]
Message-ID: <27858812.1079792.1629707601122@mail2.virginmedia.com> (raw)
In-Reply-To: <e68082c5-07a7-4c1a-b650-8656ed6b0c32@www.fastmail.com>


> On 22 August 2021 at 22:05 Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> Peter Stephenson wrote on Sun, 22 Aug 2021 20:24 +00:00:
> > Also seems a good idea to turn a null string into a couple of quotes.  I
> > thought of modifying the error message handler but this has too many
> > knock on effects.
> 
> What "knock on effects"?  Extending zwarning() with a %q format code
> that takes a «char *» and outputs it quoted seems like a good idea and
> shouldn't break anything.  Will handle filenames with spaces, too.

This is certainly all stuff that's accumulated rather than been planned
over the years, but having a harder look I think it's mostly not too bad
the way it is.  I think the basics are currently as follows.

%s as implemented in errors and warnings is already not a straight 
printf %s: it uses nicezputs() to emphasise visibility rather than quoting,
i.e. it's there to make it easy to see what the error is about, rather than
easy to copy back into the shell.  Given the error is about something that
would usually be either in a script or on the command line, this doesn't
seem a bad way of doing it, on reflection.

As far as quoting is concerned, the state of the art is to use `%s' (i.e.
with those literal quotes) if it seems necessary to draw attention to the
argument, i.e. it could get lost otherwise.  There are a  lot of cases
where we don't do this, however, but they can easily be changed.  The
combination of this and nicezputs() means you can always see what's
there, unless there are very subtle cases I've missed.

So I think the consistent way of handling a case like this is to turn
%s into `%s'.  That both makes it visible what's going on and makes
the output consistent with similar cases elsewhere.

Does that seem reasonable?  I can't think of a strong argument for a
more widespread change given it's sort of working and even sort of
potentially consistent.

pws


  reply	other threads:[~2021-08-23  8:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-22 13:45 Marlon Richert
2021-08-22 15:35 ` Mikael Magnusson
2021-08-22 19:27   ` Marlon Richert
2021-08-22 20:24 ` Peter Stephenson
2021-08-22 21:05   ` Daniel Shahaf
2021-08-23  8:33     ` Peter Stephenson [this message]
2021-08-24 13:04       ` Daniel Shahaf

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=27858812.1079792.1629707601122@mail2.virginmedia.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-workers@zsh.org \
    /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).