Command line parsers look at what you typed, not what what you typed looks like

Command line parsers are stricter than human beings. The computer cares about what you typed. If you type something else that superficially resembles what you want, but is not actually what you want, then you won't get what you want, even though it sure looks like what you want.

I covered a special case of this topic earlier when I described smart quotes as the hidden scourge of text meant for computer consumption. You think you typed a quotation mark, but the editor secretly "improves" it from U+0022 to U+201C. Then you paste the text into a command line and you get strange output because the command line parser uses U+0022 as the quotation mark, not characters like U+201C which physically resemble U+0022 but aren't. A human being would say, "Yeah, that's a quotation mark, we'll let it slide." A command line parser knows what it wants and accepts no substitutes.

Even though my original examples are for command line use, the principle applies elsewhere, and I'm going to use CSS selectors as my example, because the command line programs used in my original examples are internal Microsoft tools, and explaining their command line syntax would distract from the message. On the other hand, everybody can look up CSS selector syntax. (There is an opportunity for a snarky comment here, but I'm going to withhold the pre-emptive snarky comment in the hopes that my readers are mature enough to not go for the cheap drive-by insult. I am almost always disappointed by the result, but I try again every so often to see if the environment has changed.)

Here is an imaginary question/answer session inspired by actual events:

From: Xxxx Xxxxx

How do I make a CSS rule apply only to elements with a specific tag and a specific class? Specifically, I want a rule to apply only to elements of the form <SPAN CLASS="Name">.

From: Yyyyy Yyyyyy

You use SPAN.Name.

From: Xxxx Xxxxx

I tried that, but it doesn't work.

SPAN. Name { color: red; }

This person became one of those people who are not interested in why something works but are only interested in the magic phrase they need to type. Whether or not you believe that the "just tell me what to type" mindset is acceptable, you have to concede that if you choose to adopt that mindset, you need to actually type what people tell you to type.

In this case, the person decided that the punctuation rules for CSS are the same as the punctuation rules for English, and since English allows (and even encourages) a space after a period, then CSS should also allow it. "I mean, it looks so much better on the screen with a space after the period." (I bet these are the same people who move cities around on a map in order to produce a more visually-pleasing arrangement.)

Or maybe the person decided that the punctuation rules for CSS were the same as C++. C++ allows spaces on either side of the field selector operator. If C++ allows it, then so too should CSS.

Of course, neither case is true. CSS has its own rules for parsing, and in CSS, spaces are significant.

What I found even more mind-boggling was another question/answer session. I'm going to use the same question and answer for illustrative purposes, but in reality, the question was different.

From: Wwww Wwwww

How do I make a CSS rule apply only to elements with a specific tag and a specific class? Specifically, I want a rule to apply only to elements of the form <SPAN CLASS="Name">.

From: Yyyyy Yyyyyy

You use SPAN.Name.

From: Wwww Wwwww

I tried that, but it doesn't work.

.Name SPAN { color: red; }

I don't know what possessed this second person to take the instructions and then scramble the pieces on the assumption that, hey, the order of the pieces of the selector aren't important, as long as they're all there, right?

Comments (32)
  1. jMarkP says:

    I’ve noticed that last point in effect in natural language (where, of course, such imprecise syntax is less disastrous). People will add an adjective to the completely wrong part of the sentence, or substitute an analogous adverb for an adjective or vice-versa.

    My canonical example is from The Weakest Link (in the UK at least, haven’t seen the US version) where the final round is introduced as:

    ‘I’ll ask alternating questions’

    What’s an alternating question? Surely Anne Robinson means to say:

    ‘I’ll ask questions alternately’

    As it is the asking that is going back and forth.

    One gets the impression that the mental process goes along the lines of ‘I need the notion of alternating somewhere in that sentence, I’ll just throw it in there the first chance I get’.

  2. laonianren says:

    A CSS block is typically a list of attributes and values where the order doesn’t matter.  Perhaps "Wwww Wwwww" had incorrectly generalized this to CSS statements.  Since each of the elements of the statement (".Name", "SPAN" and "{ color: red; }") is syntactically distinct, it’s not completely insane.

  3. Mark says:

    laonianren: "I’m going to use CSS selectors as my example, because the command line programs used in my original examples are internal Microsoft tools".

  4. Mark says:

    jMarkP: Nope, you’re just insisting on the transitive version of "alternate", instead of the intransitive.

  5. Boris says:


    I see no problem with "alternating questions" (I’m in the US and the phrase is the same here). The questions are alternating between the two players (think alternating current). The singular "alternating question" would make no sense to me, but in plural it’s just fine. Would you fin it equally incorrect to say "the questions will alternate"?

  6. DWalker says:

    Alternating questions… kind of like blinking HTML tags…

  7. DEngh says:

    laonianren: That makes sense once you’re in the block.  But the original questioner didn’t understand even that, so was asking for the magic phrase that would just make things work.

    It is insane.  The original questioner was doing the equivalent of using a random name to attract someone’s attention and didn’t understand that.  If you want to talk to Fred, you typically don’t use Wilbur’s name to call out to them.

  8. Nick Tompson says:

    Nice confusing title there, "not what what you typed"


  9. Brian says:

    Funny thing about CSS is the 3 versions are all equally valid and mean slightly different things:

    SPAN.Name = a SPAN element named Name

    SPAN .Name = an element named Name contained inside a SPAN element

    .Name SPAN = a SPAN element contained inside an element named Name

    This was one of the more difficult things for me to grok when learning CSS.

  10. Daniel Colascione says:

    Ah, the computer world’s "Klaatu. .. Verada. … Necktie…Nectar…Nickel…" :-)

  11. Joseph Koss says:

    Could the issue be Babelfish?

    A language translator might reverse words that have translatable meaning, or add a space after a period.

  12. Karellen says:

    @Brian: No, ".Name" does not match elements named "Name". Rather, it matches elements whose "class" attribute, when parsed as a space-separated list of words, contains the item "Name".

    (I’m assuming that when you say ‘named Name’ you mean ‘with id "Name"’.)

  13. Kris says:

    @Brian: The second selector should be "SPAN. Name", not "SPAN .Name".

    Actually, I don’t think this is a valid selector. I wasn’t sure and actually needed to double-check in the CSS specification, which says that for an empty string, the selector matches nothing. (At least it seems to say that, though in the relevant portion: the antecedent of "it" is unclear.)

    @James Schend: Even if the article isn’t about the examples, they are still interesting and worthy of discussion. If no one replies to the point of the article, perhaps no one has anything to contribute concerning it. Not everyone has things to add regarding the topic of grammar errors people make.

  14. Wolf Logan says:

    @Kris: "Not everyone has things to add regarding the topic of grammar errors people make."

    On the Internet? Are you kidding me?

  15. David Brooks says:

    Again, I’m missing the main point of the article here, but:

    “A command line parser knows what it wants and accepts no substitutes.”

    True, but one could imagine a command line parser that accepts curly quotes as synonyms for straight quotes, so long as other syntactic ambiguities aren’t introduced. I’ve known other script-driven languages that make that concession. One could insist, or not, that curly-open is matched by curly-closed. Just because the best-known parsers are stuck on ASCII, doesn’t mean they have to.

    The quoted sentence would still be literally true, though.

    [I even called out PowerShell in the linked article as a parser which accepts curly quotes. But that’s because the parser specifically says that curly quotes can be used to quote arguments. The parser knows what it wants and accepts no substitutes – you can’t use French angle quotes to enclose arguments. -Raymond]
  16. Brian says:

    @Karellen: you’re right that was ambiguous.  I never use id in CSS, I just create a unique class if I want something to be "named"

  17. James Schend says:

    Kris, if I wanted a detailed discussion of CSS I’m sure I could find one on some other blog, and it would actually be on-topic! Here, I’d much rather see people discuss Raymond’s point, which isn’t happening because the comments are full of CSS nitpicking.

    Oh well, I give up, do your CSS nitpicking.

  18. db48x says:

    I’m not really surprised. Apparently a large percentage of people simply can’t learn to program (and let’s face it, both the command line and css selectors are pretty much programming).

  19. steveg says:

    Much like the CSS person in the post I work with a guy who just doesn’t get SQL; you can show/tell him… and he completely stuffs it up.  Fortunately he’s "merely" stuffing up SELECT statements. The day he discovers DELETE and UPDATE…

  20. Anonymous Coward says:

    I think the last user may have been confused with cooking a stew. Just throw it all in there, it’ll all be the same after you eat it.

    Also, Kris is wrong.

  21. Anonymous Coward says:

    Db48x, I wouldn’t put too much trust in the paper if I were you. It may be interesting, but it suffers from a small sample size, poor controls, omission of the one test that would have been most interesting, overinterpretation and general sloppiness.

    The results also don’t look like what we get here in Anonyland, and also seem more indicative of a subgroup of students that’s either stupid or intellectually lazy, rather than lacking in programming aptitude per se.

  22. Squire says:

    A snippet from a post from more than 10 years ago in comp.lang.javascript. I lost the name of the author, but saved the message:

    "When I read such posts, I immediately see the primary problem in better than 90% of cases — the poster doesn’t realize the compiler won’t tolerate sloppy syntax. There is nothing in their background to prepare them for an entity that, confronted with 10,000 lines of code, insists on a comma instead of a semicolon in one of those lines, and refuses to accept any of it as a result. This is an experience for which years of television viewing, however intense and dedicated, is not the proper training."

    I think it is relevant to the point Raymond is making.

  23. James Schend says:

    Raymond, you have to love how people completely focus on the examples even after you telling them specifically it *wasn’t* CSS the original emails were about.

    Would be nice if people responded to the *point* of the article instead of picking apart the example.

  24. Jonathan says:

    Well, at least Mr. Xxxxx and Mr. Wwwww had the courtesy to include in their mail actual code samples – what they have now (<SPAN CLASS="Name">) and what they’ve actually tried (SPAN. Name, etc). I can certainly imagine people saying "I tried that, but it doesn’t work." without including the actual attempted code.

    Or, Raymond may have added that for clarity purposes, saving the issue of missing samples for another post.

  25. Drak says:

    @Boris: I think the problem with alternating questions is that the questions themselves are not doing anything (or capable of such). It’s Anne who’s doing the alternating. In the case of alternating current the current itself is alternating.

    More on topic: When someone says they’ve done what I said and it still doesn’t work, I ask them: ‘Are you 100% sure you did what I asked? 99.9% is NOT enough.’ And, lo and behold, they check again and discover extra spaces or wrong characters etc.

  26. steven says:

    "And, lo and behold, they check again and discover extra spaces or wrong characters etc."

    They will check again and not discover those. People tend to simply not notice this, especially as they don’t perceive it as a problem in the first place. They will blatantly tell you they are 100% sure that they did what you told them to.

  27. Drak says:


    Nah, they check, very carefully. They know by now that if they don’t I will come down to their floor and point out the error, and they will feel very silly :D

  28. Mark says:

    Drak: day and night alternate; ice ages and interglacials alternate; questions to player 1 and questions to player 2 alternate.

    alternate, v.

    1. v.i. Of two (occas. more than two) things: succeed each other by turns. E18.
  29. mikeb says:

    This reminds me of the very odd syntax of ‘sc’ commands that take options.  for example:

    sc query type= service

    If you type that command like so:

    sc query type=service

    which would be fine with pretty much any other command line program, sc.exe chokes. Instead of parsing "type=service" as 3 tokens, it parses it as a single token.  The option’s keyword is "type=", not "type".

  30. Drak says:


    I’d agree with you except that the question asked of player 1 the first time will not be the question asked of player 1 the second time. So I feel that in this case the questions are not the things alternating. Otherwise I could possibly say that a petrol station has alternating customers, which I hope you will agree sounds sort of silly.

  31. Mark says:

    Supposedly, good Star Trek movies and bad Star Trek movies alternate, but they’re not the same movie each time.  They alternate by popularity; the questions alternate by player.

    A petrol station would have alternating customers only if there was one pump, and some clear pattern to the customers.

    Is there somewhere other than Raymond’s blog we can battle this out?  Youtube comments, perhaps?

  32. dash vs dash vs dash says:

    Which is this different dashes should I use as a parameter prefix when specifying options to a console command?










Comments are closed.

Skip to main content