Date: Mon, 4 Sep 2023 17:24:00 +0200 From: Andreas Kusalananda =?utf-8?B?S8OkaMOkcmk=?= <andreas.kahari@abc.se> To: questions@freebsd.org Subject: Re: cut off last lines of a document Message-ID: <ZPX2kLvkZpNRdo0B@harpo.local> In-Reply-To: <865y4qt2eh.fsf@ltc.des.no> References: <57be5495-97f8-4f22-9ae2-cd9712596e64@nebelschwaden.de> <uy2fdgobbejnhyctyyrbhgvhutuhtbzzxwg5wukdujyhw7h25u@74ujfxm5gjlk> <CAMtcK2qbc1jQHXJ%2Bwu0F62o6aDQKYAx3kYARuQFZLHS6DJktRg@mail.gmail.com> <a9b64c1d-02a6-45c1-aaed-85e4cf622776@nebelschwaden.de> <86edjet336.fsf@ltc.des.no> <ZPXusAY7mYSwpZH2@harpo.local> <865y4qt2eh.fsf@ltc.des.no>
next in thread | previous in thread | raw e-mail | index | archive | help
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" <kusalananda.kahari@gmail.com> 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 .
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ZPX2kLvkZpNRdo0B>