From owner-freebsd-questions@FreeBSD.ORG Wed Jul 20 17:18:18 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B6A1D16A41F for ; Wed, 20 Jul 2005 17:18:18 +0000 (GMT) (envelope-from garys@opusnet.com) Received: from opusnet.com (mail.opusnet.com [209.210.200.6]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6980343D46 for ; Wed, 20 Jul 2005 17:18:18 +0000 (GMT) (envelope-from garys@opusnet.com) Received: from localhost.localdomain [70.98.247.55] by opusnet.com with ESMTP (SMTPD32-8.05) id A756249200D6; Wed, 20 Jul 2005 10:18:14 -0700 Received: from localhost.localdomain (localhost.localhost [127.0.0.1]) by localhost.localdomain (8.13.3/8.13.3) with ESMTP id j6KHIqLk003116 for ; Wed, 20 Jul 2005 10:18:53 -0700 (PDT) (envelope-from garys@opusnet.com) Received: (from jojo@localhost) by localhost.localdomain (8.13.3/8.13.3/Submit) id j6KHIlK4003115; Wed, 20 Jul 2005 10:18:47 -0700 (PDT) (envelope-from garys@opusnet.com) To: freebsd-questions@freebsd.org References: <20050720051806.5DE721D92E@imss.sgp.fujixerox.com> <20050720053112.GC19306@orthanc.st.hmc.edu> From: garys@opusnet.com (Gary W. Swearingen) Date: Wed, 20 Jul 2005 10:18:47 -0700 In-Reply-To: <20050720053112.GC19306@orthanc.st.hmc.edu> (Mac Mason's message of "Tue, 19 Jul 2005 22:31:12 -0700") Message-ID: <35vf359z0o.f35@mail.opusnet.com> User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: 1 byte more? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jul 2005 17:18:18 -0000 Mac Mason writes: > As I recall, the convention is than UNIX text files should always end with a > newline character. I can certainly envision situations where you might not > want to have the extra \n, but it makes intuitive sense for it to be there: > having the first half of a line in one file and the second half in another > file feels very strange to me... Does it really make intuitive sense to have a "newline" where there is no new line? (Apparently, a file's first line is not necessarily a new line, depending on how it's used.) I guess the convention got started because, unlike typewriters, shells (and Teletypes, IIRC) don't do anything useful until the "carriage return" key is used, at which time, they start a new line with "newline" so the command output, if any, will start on a new line, whether it wants to or not. So their prompts don't start a new line by themselves, execting one to have just been started by the command interpreter when the command has no output or by the command when the command has output. That forced commands like "echo" to normally end with a "newline". And for commands like "cat" which don't end with a "newline", it pushed the extra "newline" into the text file. It would probably make more intuitive sense if the "carriage return" key was interpreted more as "enter", leaving command output and prompts to start each new line (even the first) with a "newline". Oh well, that ship has sailed. Most programs try to do their best to deal with text files that don't end with a "newline", though it's sometimes debatable what is the best way to handle both cases.