From nobody Wed Dec 15 20:46:35 2021 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 3C09A18F578B for ; Wed, 15 Dec 2021 20:46:35 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JDnNB6pwKz4V63 for ; Wed, 15 Dec 2021 20:46:34 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C6D0B22A7A for ; Wed, 15 Dec 2021 20:46:34 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 1BFKkYCU025513 for ; Wed, 15 Dec 2021 20:46:34 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 1BFKkY9l025512 for bugs@FreeBSD.org; Wed, 15 Dec 2021 20:46:34 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 260450] Documentation for 'sed' is misleading w.r.t. files that do not end in newlines Date: Wed, 15 Dec 2021 20:46:35 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: Unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: jwdevel@gmail.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639601195; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=EBRJL0SQDCes00Jr1D9sim89upocekmCiIl9CenTxwI=; b=T/asTs47XBxCvDmNwr6ILBG0dsKox/cSUaMHIP+c8uZ/R3b+nf7FS0CAnqx5dR0cS2ruDj pM36CvcIijnIbgIBcwDONlwePvUYmauQeJz18Lu8s5OutP3o86OXjFg7SUFMPu/FrJk/XN 4Wp2e/m9BCwwI57rn7iLto74Ae24KMYZcupK8LE070rH1ojIayS91HRTbn/KR8J6AcYcHT VxDeC7qDmKqOamaiCtOO3Yipftp2hy9bzDhRQo2MeSaBBIMhJkXzYylBca/Nk/5nYfRCf3 N3suvo50iSNLeoWlPygm5E4mRa+X66WHvmx/uzNirMibag/UcTAzQLxJieJ7RQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639601195; a=rsa-sha256; cv=none; b=VN+PSgDeHfzagpj0ozu74eh3rk4qc1jACERXtjHOyqb6zU8F5nAuPcVGasn1AqYKzSLTSu TQ+m8pVS1aWbMitnU3Gux45SrGh5KnwrJM8AhS6QeIqv5UpD3aLJVw6ZxVc7XsqakDh6J1 XKFUFW5+JaVVD1Lo9wmKW9w9nWeB5Ew2cAUXTw/XBBna2Fi5JlIAJ7LyJGOmQ9onsBOvsr GH4TSWCDaKkT6l7wWb9Bvl4GitJhYxFsd3tEBnTfl8+eRyjdQfwSh617Ce2SNgbVv89IDT 5mGgc1fYw/vDJWmcxhjPALTd1iCmSczo0AZ5EmGDSUNS+Ld75dDY5/X/XueJyw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D260450 Bug ID: 260450 Summary: Documentation for 'sed' is misleading w.r.t. files that do not end in newlines Product: Base System Version: Unspecified Hardware: Any OS: Any Status: New Severity: Affects Many People Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: jwdevel@gmail.com When a text file does not have a terminating newline, sed seems to behave contrary to its documentation. Example: $ echo -n asdf > file.txt $ wc -c file.txt 4 file.txt $ sed -n p foo.txt | wc -c 4 In other words, sed does *not* add a newline for the last line in this file. However, the sed(1) manpage says: Normally, sed cyclically copies a line of input, not including its terminating newline character, into a pattern space, (unless there is something left after a =E2=80=9CD=E2=80=9D function), applies all of t= he commands with addresses that select that pattern space, copies the pattern space to = the standard output, appending a newline, and deletes the pattern space. In my reading of this, sed should _always_ output a newline, even if its in= put did not have one. But that does not seem to be the case. A little further info: $ sed -n l foo.txt=20 asdf$ The 'l' command outputs the pattern space. In fact, this pattern space ("asdf$") is the same regardless of whether the input file has the terminat= ing newline or not. Therefore, when the docs say "... copies the pattern space to the standard output, appending a newline," this seems clearly incorrect. --=20 You are receiving this mail because: You are the assignee for the bug.=