This is solipsistnation.livejournal.com's Typepad Profile.
Join Typepad and start following solipsistnation.livejournal.com's activity
Join Now!
Already a member? Sign In
solipsistnation.livejournal.com
Recent Activity
You asked: "The distinction between CR and LF does seem kind of pointless why would you want to move to the beginning of a line without also advancing to the next line?" Back in the old days (1990 or 1991) at WPI, when we had a lab with VT220s connected over serial to a shared unix system, we used CRs without LFs to produce 1-line animations, where we'd basically set up a bunch of "frames" of animation in a textfile separated by CRs and then cat that textfile. We got pretty elaborate, and I think I had something like a 5-minute animation in my .plan for a while (this was the primary venue for these animations, showing off your leet dumb terminal skillz or something) until the sysadmin there fingered me or one of my friends from a 2400-baud modem. A day or two later we noticed that finger started converting \r's into \n's and stopped displaying beyond 10 (post-conversion) lines of one's .plan... The VT220 could do some weird bitmapped graphics things, too ("sixel graphics"), so there were even more complex animations out there, including a memorable Twilight Zone intro and the head of J.R. "Bob" Dobbs. We hacked up a fake Mac System 7 windowing system to confuse people looking over our shoulders when we were using the VT220's... In a more modern context, some command-line programs that display a progress bar update the bar's status (without extraneous scrolling if you happened to be at the bottom of your terminal window, as would happen if you only had \n and you had to print that and then a cursor-up character) by printing their progress bar updates separated by \r. For example, from wget's progress.c: ---snip /* Print the contents of the buffer as a one-line ASCII "image" so that it can be overwritten next time. */ static void display_image (char *buf) { bool old = log_set_save_context (false); logputs (LOG_VERBOSE, "\r"); logputs (LOG_VERBOSE, buf); log_set_save_context (old); } ---snip Anyway, your points are good, and I can't count the number of times I've had to help people who have edited unix files using Notepad and messed up their \n's and couldn't figure out why their CGI scripts or whatever had stopped working... Perl (even on unix) will work fine with either \n or \n\r at the end of a line, but the shell is dumb, and if the CGI began with #!/usr/bin/perl^M the user would get a mysterious "Command not found" or "Command interpreter not found" error. Fun times.
Toggle Commented Feb 16, 2010 on The Great Newline Schism at Coding Horror