From nobody Mon Sep 4 15:24:00 2023 X-Original-To: questions@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 4RfXVD47PTz4s7W8 for ; Mon, 4 Sep 2023 15:24:04 +0000 (UTC) (envelope-from andreas.kahari@abc.se) Received: from hekla.abc.se (hekla.abc.se [158.174.61.227]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA512) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4RfXVC4FLhz3PjD for ; Mon, 4 Sep 2023 15:24:03 +0000 (UTC) (envelope-from andreas.kahari@abc.se) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=abc.se header.s=default header.b=SmTzmJqJ; spf=pass (mx1.freebsd.org: domain of andreas.kahari@abc.se designates 158.174.61.227 as permitted sender) smtp.mailfrom=andreas.kahari@abc.se; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=default; bh=/Xho9hK8dZ BuKLz30r+ztn3XlXPTfxYSUdyyhHxhak4=; h=in-reply-to:references:subject: to:from:date; d=abc.se; b=SmTzmJqJGYmTo5k/c/JQNxwMrvofbyuYXdp4IWOEEJgn mQ4uIEyP9nWI1KUhynHQQi7Rhxp1A+Pq4cz9PwynIp692YifBQ3AdeK0kN/WcBMEFU9teM feChs+0T2Xzueot7x51kqLgOvWqVX2PYikQdWetySfgJa1wbNNRcXWHh2OFz67k1epbnCS SkKvK0LBIP4v1TDQBTOKIcn9ggvs2a3zc+ccSOX5Zn/2XK5vid98rm1yDb6vNubclen41K dpbTugXflX7ov2PD4oduSuGOgPf2/naMlzbtJ2aSYG+/viTYWyOKSPC7cwHxPwQyCyaZ7a aQFNM0gKyLP2DwZj1A== Received: from harpo.local (94-255-242-14.cust.bredband2.com [94.255.242.14]) by hekla.abc.se (OpenSMTPD) with ESMTPSA id ad969722 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Mon, 4 Sep 2023 17:24:01 +0200 (CEST) Date: Mon, 4 Sep 2023 17:24:00 +0200 From: Andreas Kusalananda =?utf-8?B?S8OkaMOkcmk=?= Sender: owner-freebsd-questions@freebsd.org To: questions@freebsd.org Subject: Re: cut off last lines of a document Message-ID: Mail-Followup-To: questions@freebsd.org References: <57be5495-97f8-4f22-9ae2-cd9712596e64@nebelschwaden.de> <86edjet336.fsf@ltc.des.no> <865y4qt2eh.fsf@ltc.des.no> List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <865y4qt2eh.fsf@ltc.des.no> X-Spamd-Bar: -- X-Spamd-Result: default: False [-2.54 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-0.99)[-0.992]; NEURAL_HAM_SHORT(-0.99)[-0.986]; R_MIXED_CHARSET(0.83)[subject]; R_DKIM_ALLOW(-0.20)[abc.se:s=default]; R_SPF_ALLOW(-0.20)[+ip4:158.174.61.227:c]; MIME_GOOD(-0.10)[text/plain]; ONCE_RECEIVED(0.10)[]; PREVIOUSLY_DELIVERED(0.00)[questions@freebsd.org]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_ONE(0.00)[1]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:8473, ipnet:158.174.0.0/16, country:SE]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MLMMJ_DEST(0.00)[questions@freebsd.org]; DKIM_TRACE(0.00)[abc.se:+]; TO_DN_NONE(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; DMARC_NA(0.00)[abc.se]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[] X-Rspamd-Queue-Id: 4RfXVC4FLhz3PjD Sorry, this is resent due to a misconfiguration of my mail client. On Mon, Sep 04, 2023 at 04:54:14PM +0200, Dag-Erling Smørgrav wrote: > "Andreas Kusalananda Kähäri" writes: > > Note how this will handle backslash-escaped newlines in the input, and > > that, depending on the shell and its configuration, the "echo" call may > > or may not expand backslash-escaped characters in the input (e.g. "\n" > > and "\t"). The "echo" may also interpret the string "-n" as an option > > it occurs on its own line. You may also lose flanking whitespace. > > Right. If your shell is broken, use read -r and replace echo with > printf "%s\n". Or don't use a broken shell. > > DES > -- > Dag-Erling Smørgrav - des@FreeBSD.org Don't forget to also set IFS to an empty string. Apart from the issue that comes from having a too feature-full "echo" implementation, the rest of the issues are due to the POSIX specifications of the "read" utility. If POSIX is broken or not is a discussion I'm not getting into. -- Andreas (Kusalananda) Kähäri SciLifeLab, NBIS, ICM Uppsala University, Sweden .