From: sirjofri <sirjofri+ml-9fans@sirjofri.de>
To: 9fans <9fans@9fans.net>
Subject: Re: [9fans] Re: How do you deal with newlines (line feed, LF, \n) in filenames?
Date: Sat, 10 Aug 2024 23:48:39 +0200 (GMT+02:00) [thread overview]
Message-ID: <f97afc4e-bc06-4787-8a58-4af1e35b71db@sirjofri.de> (raw)
In-Reply-To: <17233255580.EbFBd.400013@composer.9fans.topicbox.com>
10.08.2024 23:32:48 kalterdev@gmail.com:
> Thank you for your reply. I was referring to having newlines specifically in filenames. Sometimes it's not one's own fault that filenames have them.
Sure, that can happen. I just wonder who would do that on any system.
> I wasn't really speaking about the way to represent a newline in rc, although thanks for details on that problem. My problem is to parse command output that has a newline in a filename.
>
> On my system, find(1) just prints the newline as is. So if the output looks like this:
>
> a
> b
>
> It is actually possible that it means one "a\n" file, not file "a" and file "b".
I think in this case it would be either two files ("a" and "b") or one file ("a\nb") because otherwise it would look like this:
a
b
> Some commands, including ls(1) from plan9port, support quoting such files. But then the problem is how to parse them.
Yeah, that's more complicated then. I don't think we have standard tools to deal with that situation out of the box yet.
That is, if you're lucky enough to have an ls, walk or find that can quote them, you can parse them using different tools (awk, sed, or build them yourself in C). It would probably easier to circumvent this by getting file by file, for example using some dirstat counterpart or maybe even a for loop (but I think for loops also work with command output).
Maybe someone else can help you find a more pleasing solution, sorry.
sirjofri
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T11149f1f949593f5-M57ab58e7079320469579f89b
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
prev parent reply other threads:[~2024-08-10 21:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-10 20:46 [9fans] " kalterdev
2024-08-10 21:05 ` sirjofri
2024-08-10 21:32 ` [9fans] " kalterdev
2024-08-10 21:48 ` sirjofri [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f97afc4e-bc06-4787-8a58-4af1e35b71db@sirjofri.de \
--to=sirjofri+ml-9fans@sirjofri.de \
--cc=9fans@9fans.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).