Backslash-Quote: The Greatest Bug of All

When the earth was cooling, computerists, probably those Kernighan & Ritchie guys, figured C-language programs should have command-line arguments, and they made it so. At that moment or shortly afterwards, people wanted command-line arguments with spaces in them, which was supported by quotes. Thus, one could go grep phrase *.txt or grep "phrase with spaces" *.txt. Both ways! Total flexibility!

But then the guru masters realized they must do something; what if someone wanted a quote in the argument? So they introduced the backslash-quote, i.e. grep "he said \"Hi\"" *.txt. It was a backslash presumably because C-language already used that punctuation in C-language literals and printf syntax to indicate special characters, including quote marks, control characters, random hex values. ... But only the double-quotes were “escaped” for the command-line.

This was a terrible error, because they didn’t provide for escaping the backslash itself! They only used it as an escape character when it came before a double-quote mark, and otherwise just passed it through. Perhaps they wondered, who could possibly be stupid-enough to need an argument like “c:\windows\stupid directory\”?

... Of course, they hadn’t met Bill Gates. ... MSDOS and later Windows had directory paths just like decent operating systems (i.e Unix) except to make them different, they used the backslash instead of the forward slash. To make absolutely sure everything was screwed-up forever, the option character, normally a - hyphen in Unix, was a forward-slash in MSDOS. Also, incidentally, the path separator was changed from a colon to a semicolon. ... Perhaps there had been some wacko software patent action contemporary to the bad dreams of MSDOS’ architects, but that’s what they did.

Windows 95

And then, Windows 95 and some version of NT introduced spaces in file and directory names. From there it was only a matter of minutes probably before somebody tried to describe a directory in a command-line like stupid-program "c:\stupid directory\" arg3 and failed utterly: the stupid-program would see a single argument c:\stupid directory" arg3 with that wacky double-quote stuck in the middle and nothing would work.

Today, all the compilers I tested include an additional “feature”: the sequence \\" will be seen as a single backslash, followed by a double-quote[1]. I know that the old Borland compilers I have, year 2000 and back, did not have this additional feature, so with programs compiled under those compilers it is impossible to use properly-backslashed windows spacey-directory arguments. ... As I learned to my sorrow while I was trying to beat into submission Corel X4 recently, which does only recognize a directory in certain contexts if it has a final backslash....

I believe that the pre-2001 Borland state of bugitude lasted through much of the history of the feature; I don’t have an adequate supply of antique compilers (!) to really tell, but my guess is Borland stole the feature from some Unix or Microsoft compiler around 1988, and probably at least at that time nobody provided the \\" fix.

It’s Not a Feature; It’s a Bug

For me, the beauty of this feature is my sense of millions of users, over the wandering years, trying to pass windows directories to various command-line utilities, and utterly failing. ... It’s poetic. A very small percentage of them will guess that the \\" feature is available — if it is — but most of course won’t. ... And often, command-line utilities are actually used by other programs, batch files, whoever, where the “feature” just fades out of sight into the maelstrom of chaos that is Windows (or really any recent OS). .. Of course we could all just Read the Fine Manual; but giant $500 programs hardly have manuals anymore, and pitiful Windows command-line utilities — never.

— the strangely-amused programmer
Monday, November 9, 2009 5:33 pm


1. Actually I realized later my beloved Borland Builder version 5 — beloved, because I can’t see paying $1000s for a probably more-broken copy-protected upgraded .net-based (!!) monstrosity — has the \\" feature, sort-of, but does it wrong. Of course. So if I want "c:\windows\stupid directory\" it’ll produce c:\windows\stupid directory\" — strange trailing quote — which isn’t terribly helpful. As my beautiful arguments.zip might demonstrate. Note that arguments.zip there includes exciting and almost-certainly deadly fixit code for the problem; typing it without arguments probably won’t crash and will tell you how to see for yourself the exciting results — and perhaps if your compiler is like that, fix it also. Please note the included source code isn’t nearly as bad as it looks; like Mark Twain I believe said of Wagner (“not nearly as bad as it sounds”). ... And then I got guilty and wrote a beauteous C-language version; so there are two things in arguments.zip, argument.cpp with the C-- borland command-line arguments fixer and handy house destroyer, and a comparably talented plain old C-language version arg2.cpp — which, to be sure, is still a CPP file, a practice I follow since the error-checking’s more annoying. Both of these fixits, incidentally, as well as rendering "\stupid directory\" correctly, also can embed quotes by doubling, i.e. "\really ""stupid"" directory\" would produce \really "stupid" directory\ — and heck with Windows 8, it could happen! — and even edge conditions like """\really"" stupid\" and "\really ""stupid""", producing respectively "\really" stupid\ and \really "stupid". ... Amazing isn’t it?

FINDJ: A Logical Grep

Just like Spock! So much more sensible. ... No, not really; you should assume findj is bad and dangerous and will erase your hard drive almost instantaneously, but here in the attic, at last, I can go

findj "balm&gilead" c:\gregor\textkeep\bible.txt

and if you had the Guttenberg Project ASCII bible text, your copy might also print

::::::::: c:\gregor\textkeep\bible.txt
8:22 Is there no balm in Gilead; is there no physician there? why then
46:11 Go up into Gilead, and take balm, O virgin, the daughter of

Get it here, with complete obsolete Borland version 5 C++ source! ... And, absolutely free of charge, a BSD-style (free free free!) license therein. ... Note that this is a slovenly wasteful ungreppish thing, which stows the entire file in memory. That could be fixed but I’m not going to. ... But on the other hand, it’s survived minutes of testing!

It prints a supposedly-informative message if invoked without arguments....

... and A Few More Dubious Utilities

While I’m at it, here’s sortj, sumj, and randj, which sort, add-up, and randomize respectively ASCII lists. All are of the memory-wasting whole-file-in-memory persuasion, like findj. And randj is particularly pitiful. ... Won’t we have fun?!?! — after you clean-up the extensive damage these harmless bits of pestilential software will wreak on your computer, your home, and your innocent pets.... Jgotabs is a much scruffier sort of thing, but the others are disdainful of those nasty tab characters, so it might be handy. And it might even work! ... Although, again, do hide the pets....

... And then again, for something entirely different, let’s take a stroll amongst the shacks and tents down by the water and the cannery, and see how the peasants live! Specifically, how we wrote programs when men were men and programmers were probably impaired in numerous dubious ways: my precious, my only, a legacy of my misspent productive years, JGODIR! ... You don’t need it, I don’t need it, but I started it on 12/15/93!!! ... I vaguely recall I concocted this for an associate in a distant land — Pennsylvania I think. ... I would send him various software I had concocted — probably by modem by then, I think the days of mailed diskettes were over, but who can tell? But one day the stuff I sent couldn’t be deleted, it was a virus! ... I have a vague guilty memory of my making it read-only, to correct some other amazing problem we were supposedly having, but anyway I suspected that, and so I borrowed some code from my almost-as-fascinating OwenView so I could send him a command-line directory utility that, as opposed to the MSDOS DIR command, would show the file’s attributes; and I think the strategery actually worked. And I’ve found JGODIR strangely useful over the years, for its wacko formats and what-not. ... But you almost certainly won’t, if you survive the destructive matter-anti-matter collision which will infallibly occur if you ever are so foolish as to run the program....

And then Monday, February 11, 2013 I discovered I was reporting file times in UTC aka “Coordinated Universal Time” but in some barbarous language, aka Greenwich time! ... So sophisticated ’n’ all. ... I might make it an option someday, but I think I’ve got it to tell the real time now....

CBuilder (Version 5, 2000) Tips ’n’ Trickery

Aka the last decent version; aka the “version I own”. ... Up there I explain about “\stupid\backslashes\” in quoted command-line arguments — but there’s more! .... Builder and Turbo C and the other awful Borland Cs (but still much better than Microsoft!) had a conio library where you could make these cute little windows with, of course, mono-spaced fonts, like the beautiful illustration. But when Windows 7 and its hideous 64-bit snootiness rushed at me (see antiques for more on that), my old 16-bit Turbo C (1988) programs wouldn’t work until I added a “textmode(C80X50)” call to them; then they would beautifully locate their primitive characters in a typical 80-character 50-line console screen and all was good and new again. ... The “C80X50” constant came from a large collection in conio.h, all of which, constants and calls alike, are apparently undocumented in Builder and, as usual, my helpful suggestions are likely to melt your car at least if not your appliances and children, but nevertheless I am so happy that I got this stuff to work....

— the kindly programmer
Thursday, March 10, 2011 1:41 pm

The Dark Side of the Arduino

In my role as the only being in the entire known webiverse who will say anything bad about anything, here at last are the astonishing hidden secrets of the world-famouos Arduino hobbyist experimenter board:

  • Some wonderful Italians created this FOSS project, which consists of hardware — an adorable little board with an Atmel/AVR microprocessor on it, originally thru-hole (aka “antique”) to make it easier for hobbyists — and software: an IDE for you to write your programs, and an entire c-like programming language to write them in!

  • I must admit I assumed for some time that the Arduino Programming Language (as it’s ingeniously known) was an interpreter, probably because some idiot on the web or a magazine said so (including in days of yore my helpful entry). Which would make it really really stupid if you can’t breakpoint or single-step in the Arduino system. Which you can’t.

  • But in fact the language is C++, with “EZfied” features: “Your sketch [aka your Arduino progra in their quaint argot] undergoes minor changes ... and then is passed directly to a C/C++ compiler” (http://arduino.cc/en/Main/FAQ).

  • But you can’t use ICE h/w or whatever it’s called this week with the Arduino language. So even if you have one of the ($350?) Atmel in-circuit debuggers, you still can’t single-step or breakpoint. At least in the Arduino language/environment.

  • To summarize, it’s bad because it’s stupid to make an EZ-to-program system which is hard-to-debug. (See this stack overflow summary, which references a dubious-looking Visual Studio plug-in Arduino debugger for sale.)

Delusional Rant

And I know why the Arduinistas did that: because real men, at least in my wonderful embedded system world, debug with a few toothpicks and printf statements; they don’t need no stinkin’ ridiculously expen$ive debugging equipment! ... Which, but a little while ago, in these guys’ formative years, were, like everything else in our hideous denegerate free-market capitalist greed-ruled world, much more expensive. ... Actual mortals, like myself, nevertheless need debugging equipment, at least if we want to do anything beyond the abysmally simple. We need breakpoints and single step.

And I am an expert, and I never lie. And it isn’t just my delusional rant, it’s an official programming verity that debugging takes at least twice as long as writing the program. When I googled “arduino debugging” the best I got was this stackoverflow discussion, which suggests upgrading to an AVR debugging environment. Otherwise, as an Arduino forum points out, “during development, we all use Serial.print() to help debug our code”. Which is what they did with the teletypes in olden days when men were men....

Compared to many educational / hobbyist products and others, the Arduino is still ridiculously functional per $. And perhaps I will find-out how it’s possible to debug with “Arduino Language”, although not, apparently, from the Arduistas. ... It’s like my beautiful toy sextant , made somewhere in the wide wonderful world so it looks like a genuine antique instrument — but, sadly, not actually so good at sextanting. ... The Arduino shares its traditional ’n’ quaint socket/thru-hole[1] CPU style with other hobby offerings, but adds open source goodness and a resulting large competitive market of compatible products and add-on boards (in Arduino-speak, “shields”!?). ... So it’s good. ... But not all good....

Arduino Mega 2560: Knave or Fool?

And as I and the Arduistas wander through the years, I eventually got their lovely Mega 2560 board for a pittance, and then dawdled for a few months, and finally went to get the Eagle schematic and PCB files, which are a standard part of the wonderful and uplifting open source deal. ... And there were none! ... There were such files for the despised revision zero Mega 2560. Which is not the board I bought; with the Arduino logo on it and everything! ... It’s “despised”, because I assume if it was changed — twice! — so early in the young board’s history, there was something regrettable about revision zero. ... What I got is the “MEGA 2560 R3”, as is printed right on the bottom of the board; without my italics of course. ... But the Eagle file I found on the web “arduino-mega2560_R3-reference-design.zip” was not good; it was a broken zip, which would unzip not!

Knaves?

... I must say, for a few days, even a week, I figured things must be really sad over there in Arduino land; the classic organizational sclerosis must’ve set in, if they had become so stupid they couldn’t post a valid zip file. This is the sort of thing Bob’s Software and Used CDs would do. ... But then the snake whispered in my ear: perhaps, in the classic “Knave or Fool” dilemma, we have not the fool here? ... Perhaps, the Arduistas are tired of the cloners churning out their designs in a few days, robbing all the obscene profit from the otherwise wholly pure and noble Arduino enterprise? ... The Arduino folks must have the Eagle files to produce the board; surely they’re capable of zipping them up and posting them? I mean, I could do that in my sleep. ... But when they post the Eagle files promptly, the cloners get right to work with their shoddy cheap exact entirely legal imitations....

Fools

But later, I realized everything’s OK. ... They’re not venal but, indeed, just fools. ... Eventually they posted a working zip file which still wouldn’t open in Eagle. Legions of the usual idiots forum participants posted assurances that sure absolutely it really really worked this time. Since I had already applied zip-file fixit tools to the broken zip and achieved a similar result — i.e., it would unzip, but the resulting supposed-eagle files wouldn’t open in Eagle — I assumed the notional Bob’s Software idiot-in-chief had just done the same. ... But no; the arduweeny are not so easy. What they did was post a working zip file with working Eagle files in it — but for a different version of Eagle! ... This sort of creativity is the mark of the True Cluelessness! ... That is, the Eagle files of arduino-mega2560-reference-design.zip aka “Rev 0” opened good in Eagle version 5, but arduino-mega2560_R3-reference-design.zip’s files, cunningly, would only open in Eagle version 6. ... Not so terrible, since to just look at the file, Eagle’s a free download — but that’s true only if you tell people!

Now there were a few vagrant posters who claimed it’d open great in Eagle 6, along with the people who insisted the zip file was never never broken; and of course the apparently officialish poster who said the broken zip file was a “known issue”. ... Such are the ingredients for truly great broken software, and I doff my cap to the arduweeny masters. ... And I still suspect the “broken” zip file was a bit of anti-cloner medicine....

Other Dirt

In my self-appointed role as ombudsthing, I will now complain about the Arduino IDE version 1.0: in repeated tests, it failed to burn the bootloader back into my pitiful tiny ATmega2560. Well, two tests; I tried it with Sparkfun’s $20 “Pocket Programmer”, using drivers from Adafruit since Sparkfun never bothered to update for Windows 7; but Arduino wasn’t happy when I selected the “USBtinyISP” programmer. And an official Atmel AVRISP mkII ($45 from Newark) also failed. ... I have actually accomplished this magnificent undertaking with AVR studio 4 + Atmel equipment including the AVRISP mkII, so I must sadly conclude the “Burn Bootloader” thing doesn’t work. ... Also, the Italian financial crisis has apparently embargoed the acquisition of progress bars, with which the Arduino IDE appears to be completely unacquainted at least when burning boot loaders. ... I suspect there are Windows-versus-Linux/Mac issues: i.e. perhaps the Windows version of various free utilities (as used by the Arduino IDE) are not so well supported because ATMEL/AVR gives away vast and amazing Windows-only software gadgets that do the job fine, if with a few eccentric gigabytes of download. Or perhaps it’s just stardust....

Atmel/AVR Programming

While I’m at it, let me whine some more about Atmel/AVR hardware. ... A great attraction of the Arduino IDE is it doesn’t require expensive equipment to burn your program into your Arduino. When you buy a genuine Arduino, it is already programmed with an Arduino “boot loader” which the Arduino IDE uses to load your compiled program. But no matter how admirable this scheme, somehow the boot loader occasionally departs for realms unknown, and then the poor hobbyist has to buy another Arduino. Which makes it less cheap ’n’ EZ. Or he might use a hardware programmer, which he doesn’t have because the Arduino is so cheap ’n’ EZ....

Atmel/AVR hardware programmers are certainly available in great abundance, some of them pretty cheap, and the Arduino IDE may someday be able to reburn your poor Arduino’s boot loader, but not when I tried. ... Actually there are about 5 million Atmel/AVR programmers out there, presumably because Atmel/AVR is so popular and the hardware design requirements are fairly cheap. I suspect a large number of them don’t actually work, or haven’t worked for a few months, years, or forever, or perhaps don’t work with whatever Atmel part you happen to wish them to work with, or require a parallel port or obsolete versions of Windows or Heaven knows what. ... But it seems as if every Atmel/AVR project I find on the web uses a different hardware programmer. ... And every commercial source, i.e. web page / columnist, not only uses a different programmer, but uses one in which they somehow have a financial interest. ... And if you ever think you’ve got a working programmer, you still have to figure-out how to reprogram the boot loader if the Arduino IDE won’t do it, which so far I can only regard as foolishly ambitious....

AVRdudeGUI

I will add my little pittance to the mix of chaos and obscurity, and note that a dangerous ridiculously-named FOSS program “AVRdude” (“Downloader / UploaDEr”, they claim) is apparently the goto software for burning your AVR/Atmel debris using many of the wandering herds of occasionally-functional programmers. It is the instrument used or not by the Arduino IDE to achieve this exalted goal, and like all good FOSS programs has, I believe at last count, 5,734,312 command-line options. There are various free “GUI” AVRdude-handlers, but the one I randomly picked-up was called “avrdudeGUI” and seemed to work good — in the sense that such command-line GUI prosthetics provide a nearly-crucial service of showing what categories of options are available, in this case showing me that AVRdude will happily adjust the fuses on your target Atmel gadget, a subject I had been agonizing over. It didn’t show me how to adjust them of course — that’d be telling! — and if you don’t adjust the fuses right, nothing works. As opposed to the normal state where nothing works....

Telepathy

And another thing: I am apparently the only being who cannot telepathically determine how the 6-pin Atmel ISP connector is supposed to go. All others, at least among the yammering multitudes on the forums, never encounter any difficulty and can just stuff it in without thought; although so far all the equipment with the fixture I’ve encountered have less than ideal markings, ranging from slight to none. The Arduistas do put a tiny white dot on pin 1, which is generous of them. ... But that’s the best it gets....

Atmel Studio 6?

But I must not leave the Arduistas without noting the lamentable crankiness of the competition, the official Atmel/AVR software environment “Atmel Studio 6”, also free of cost. We software engineering types are accustomed to awful software “tools” — that’s why I wrote my own 68HC11 assembler — and Studio 6 does not disappoint. Within the last days I’ve already gone through the canonical “oh you’re using the old version” excuse, beloved of old and young. Which with cranky software is almost always true, since it’s always being bug fixed upgraded. ... The total absence of example projects — a sure stigmata of the broken and beautiful — is because everyone including the authors, assuming there are any at fixed addresses, has difficulty making the product work, at least for more than a week — that is, anyone who posts an example is doomed to next week’s failure if not sooner at the bug fix upgrade. .... Such is a significant justification for the Arduino project: there are Arduino crotchets, but it still works better than Studio 6....

But Studio 6 has breakpoints and single-step debugging, or at least it says it does and hope springs eternal, and indeed with aquaintance comes tolerance and eventually no doubt I will aver, like all the craven fans at the avrfreaks forum — it’s not so bad. ... And of course I must note that all is superceded by the beautiful and totally-functional Studio 7....

Late News — They’re Fightin’!

At 4/15, Schadenfreude fans everywhere are gathering around the Arduweeny cat fight, where two would-be Mr. Arduinos are battling it out in the courts over who owns the name. So edifying and gratifying....

— the thoughtful compassionate programmer
4/5/15


1. I, too, am fond of thru-hole socketable parts. And apparently large numbers of hobbyists and I’d suspect some back-alley professionals are also, since the parts vendors still seem to keep quite a few available. But one cannot fit a 112-pin CPU into a 48-pin socket, and the 48-pin socket is already too big. So time marched on. ... Recent Arduino offerings have, in fact, turned to a darker side and use SMT devices....