Skip to content

Failglob woes: Recommend quoting - #3919

Closed
anordal wants to merge 2 commits into
fish-shell:masterfrom
anordal:failglob_woes_recommend_quoting
Closed

anordal wants to merge 2 commits into
fish-shell:masterfrom
anordal:failglob_woes_recommend_quoting

Conversation

@anordal

@anordal anordal commented Mar 27, 2017

Copy link
Copy Markdown
Contributor

Description

The first commit moves the prefix part of all error messages. This is to resolve doubt about where the first part of the message comes from; the second part is the context, so that says itself.

The second commit changes the wildcard error message. Apologies for breaking all the translations, I have contributed the ones I can.

Fixes issue #3649

TODOs:

  • Changes to fish usage are reflected in user documentation/manpages.
  • Tests have been added for regressions fixed
  • User-visible changes noted in CHANGELOG.md

Comment thread po/en.po Outdated
msgid "No matches for wildcard '%ls'."
msgstr "No matches for wildcard “%ls”."
msgid "No matches for wildcard pattern '%ls'.\n"
"(Tip: To avoid wildcarding, quote it. To allow no matches, expand it to a variable.)"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"expand it to a variable" may not be clear enough. Something like "assign the glob to a variable" may be better.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the concern?

Replacing "expand" with "assign" may be more beginner friendly, but at the cost of preciseness: It might also be understood as quoting the glob when assigning the variable, hoping the glob will instead be interpreted when the variable is expanded (which we thankfully don't support, unlike bash).

I've opted to call it "wildcard pattern" instead of "glob". Isn't that what we call it in the more user-facing documentation?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because "expand it to a variable" is grammatically awkward and therefore likely to confuse some users. I can't find a single instance of "wildcard pattern" in the docs or source. There are 36 lines in doc_src containing "wildcard" and 40 containing "glob". So if you want to say "No matches for wildcard '%ls'.\n" that's fine by me. I'd also replace "wildcarding" with "wildcard expansion".

@krader1961

Copy link
Copy Markdown
Contributor

This LGTM other than the wording of one message that may be unclear.

Comment thread src/parse_constants.h Outdated
#define WILDCARD_ERR_MSG \
_(L"No matches for wildcard '%ls'. (Tip: empty matches are allowed in 'set', 'count', " \
L"'for'.)")
_(L"No matches for wildcard pattern '%ls'.\n" \

@ridiculousfish ridiculousfish Mar 30, 2017 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Frankly the existing Tip drives me nuts. A tip seems appropriate if it either only shows a few times, or if it always indicates a user error. But failed wildcard expansions are something users (or at least I) encounter often, so I don't think any tip is appropriate here.

I would like to drop the Tip and simply say "No matches for wildcard pattern '%ls'.

@krader1961

Copy link
Copy Markdown
Contributor

Like @ridiculousfish I'm not happy with the "tip" portion of the message. Especially since the issue this PR is meant to address requires quoting the string containing the wildcard characters, not using the string in the context of a set or for statement. I think it would be better to simply revise it to say something like No matches for wildcard '%ls'. Perhaps you need to quote it..

@anordal

anordal commented Apr 3, 2017 •

Copy link
Copy Markdown
Contributor Author

Suggestions:

  1. No matches for wildcard pattern '%ls'.
  2. No matches for wildcard '%ls'. Perhaps you need to quote it.

From a translator's viewpoint, 1 is straightforward, while both sentences in 2 are difficult: In Norwegian, you have to say either wildcard character or wildcard pattern (less ambiguity = less guesswork for the translator), there is no verb for putting things in quotes, and there is no unifying word specifically for ASCII single or double quote (without implying other citation signs like «»), which makes the translation much longer than the original.

The other reason I prefer to say "wildcard pattern" is that that's what the caret is pointing at (not the wildcard character(s)). Maybe wording accuracy can make up for the accuracy of the caret.

@faho

faho commented Apr 3, 2017

Copy link
Copy Markdown
Member

Soo... there's four things we might want to mention here:

  • The wildcard failed to match anything

  • The command wasn't executed as a result

  • Wildcards in quotes (single or double) aren't expanded

  • Empty wildcard matches are allowed in set, for and count

It seems @ridiculousfish prefers only mentioning the first - if so, I'd like to at least include a link to the appropriate documentation. That would be

Wildcard '%ls' failed to match anything. See `help expand`.

(and then maybe polish the docs a bit, and possibly offer a man-page version of that)

For a more maximalist wording, how about

Wildcard '%ls' failed to match anything. The command wasn't executed.
(To avoid wildcard expansion, use '%ls' or "%ls". Empty matches are allowed in `set`, `for` and `count`)

?

@krader1961

Copy link
Copy Markdown
Contributor

FWIW, I prefer @faho's minimalist error message. I don't think the "tip" in the maximalist error message is an adequate replacement to simply pointing the user to the even more verbose documentation on the subject.

@anordal

anordal commented Apr 4, 2017 •

Copy link
Copy Markdown
Contributor Author

But is "wildcard pattern" better, or is it just me?

Two minimalist options (with "wildcard pattern"):

Wildcard pattern '%ls' failed to match anything. See `help expand`.


No matches for wildcard pattern '%ls'. See `help expand`.

I find the "No matches" one easier to translate.

@anordal
anordal force-pushed the failglob_woes_recommend_quoting branch from 4cefc1a to 10f7bff Compare April 4, 2017 20:24
@krader1961

Copy link
Copy Markdown
Contributor

The phrase "wildcard pattern" is somewhat redundant in the context of a UNIX shell. And as far as I can tell appears nowhere else in our core source, functions, or documentation. Having said that I like the "No matches..." message and in that specific context the use of "wildcard pattern" is justifiable. Another option is something like

String '%ls' contains wildcards but failed to match any files. See `help expand`.

Obviously at this point we're getting dangerously close to bikeshedding. So I'm happy to approve your "No matches for..." variant if no one else has an opinion on the matter.

@ridiculousfish

ridiculousfish commented Apr 11, 2017 •

Copy link
Copy Markdown
Member

This is one of those error messages that will get tripped a lot. It's all about communicating what happened and enabling the user to move on ASAP. I agree "wildcard pattern" is redundant, but I'm satisfied with:

No matches for wildcard '%ls'. See `help expand`.

Sidebar: tcsh is a fun data point for brevity:

> tcsh -c 'echo none*'
echo: No match.

k.

@krader1961

Copy link
Copy Markdown
Contributor

Thanks, @anordal. I've merged this as commit 08d42a0 with the minor change from "wildcard pattern" to "wildcard". I only changed the english wording since I had no idea what to change the non-english equivalents to.

@anordal

anordal commented Apr 16, 2017

Copy link
Copy Markdown
Contributor Author

Thanks, @krader1961. The non-english translations are okay (because unlike English, they cannot be shortened without meaning something else), but there was a leftover "p" in the msgid in po/nb.po.

@anordal

anordal commented Jul 3, 2017 •

Copy link
Copy Markdown
Contributor Author

For reference, the empty matches are allowed in 'set', 'count', 'for' text (which got replaced here) was added in #3101.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants