Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: Reading a list of null-terminated filenames from stdin?
(Andrew Bernard)
2. Re: Reading a list of null-terminated filenames from stdin?
(Brandon Allbery)
3. Re: Reading a list of null-terminated filenames from stdin?
(Rustom Mody)
4. Re: Reading a list of null-terminated filenames from stdin?
(Andrew Bernard)
5. Re: Reading a list of null-terminated filenames from stdin?
(Harald Hanche-Olsen)
6. Re: Reading a list of null-terminated filenames from stdin?
(Imants Cekusins)
7. Re: Reading a list of null-terminated filenames from stdin?
(Harald Hanche-Olsen)
8. Re: Reading a list of null-terminated filenames from stdin?
(Michael Snoyman)
----------------------------------------------------------------------
Message: 1
Date: Sun, 11 Oct 2015 16:01:17 +1100
From: Andrew Bernard <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Reading a list of null-terminated
filenames from stdin?
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
Hi Dan,
On what operating system can filenames contain newlines?
Andrew
> On 11 Oct 2015, at 05:45, Dan Stromberg <[email protected]> wrote:
>
> The goal is to be able to operate on filenames that contain newlines, but
> it's not that end of the world if that isn't very practical.
------------------------------
Message: 2
Date: Sun, 11 Oct 2015 01:13:38 -0400
From: Brandon Allbery <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Reading a list of null-terminated
filenames from stdin?
Message-ID:
<cakfcl4unxp3fnt7ncjy4qt1jo28hanedzoi+bqhqn1ckxdn...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On Sun, Oct 11, 2015 at 1:01 AM, Andrew Bernard <[email protected]>
wrote:
> On what operating system can filenames contain newlines?
Any unixlike system. You would need to quote the newline from the shell,
but it is perfectly valid.
--
brandon s allbery kf8nh sine nomine associates
[email protected] [email protected]
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20151011/9b5e73ad/attachment-0001.html>
------------------------------
Message: 3
Date: Sun, 11 Oct 2015 10:58:28 +0530
From: Rustom Mody <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Reading a list of null-terminated
filenames from stdin?
Message-ID:
<CAJ+TeofT1_HMT8fB7zfyfW4h6GYNA=+780uaoup12_sofjm...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On Sun, Oct 11, 2015 at 10:43 AM, Brandon Allbery <[email protected]>
wrote:
> On Sun, Oct 11, 2015 at 1:01 AM, Andrew Bernard <[email protected]>
> wrote:
>
>> On what operating system can filenames contain newlines?
>
>
> Any unixlike system. You would need to quote the newline from the shell,
> but it is perfectly valid.
>
Valid... Ok
Perfectly?? Here's a counter view
http://www.dwheeler.com/essays/fixing-unix-linux-filenames.html
Summary: Funny chars in filenames is a feature close to a bug in *Nix
filesystems
So my advice for this would be:
- If you have better things to do dont bother
- if for some reason you do need to bother, respect Postel's law
<https://en.wikipedia.org/wiki/Robustness_principle> and allow it out more
reluctantly than in
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20151011/ac6f67e1/attachment-0001.html>
------------------------------
Message: 4
Date: Sun, 11 Oct 2015 17:24:40 +1100
From: Andrew Bernard <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Reading a list of null-terminated
filenames from stdin?
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
Hi Brandon,
It may be valid, but it is just asking for trouble with many tools and
utilities and scripts. Funny, I had to check re UNIX. I have been programming
UNIX systems for over thirty years and never even imagined a newline in a
filename!
Would the OP say why he needs to use newlines in filenames? Something best
avoided. I suppose this is not a Haskell matter, but one does have to ask.
Andrew
> On 11 Oct 2015, at 16:13, Brandon Allbery <[email protected]> wrote:
>
>
> Any unixlike system. You would need to quote the newline from the shell, but
> it is perfectly valid.
------------------------------
Message: 5
Date: Sun, 11 Oct 2015 11:22:34 +0200
From: Harald Hanche-Olsen <[email protected]>
To: The Haskell-Beginners Mailing List <[email protected]>
Subject: Re: [Haskell-beginners] Reading a list of null-terminated
filenames from stdin?
Message-ID: <[email protected]>
Content-Type: text/plain; charset=windows-1252; format=flowed
Andrew Bernard wrote:
> Hi Brandon,
>
> It may be valid, but it is just asking for trouble with many tools and
> utilities and scripts. Funny, I had to check re UNIX. I have been programming
> UNIX systems for over thirty years and never even imagined a newline in a
> filename!
>
> Would the OP say why he needs to use newlines in filenames? Something best
> avoided. I suppose this is not a Haskell matter, but one does have to ask.
The OP must speak for himself, but as far as I am concerned, no
reasonable person uses newlines in filenames, ever.
However, the possibility is there, and it may happen that someone
unreasonable has created a filename with a newline in it. This may
become a security issue if, for example, someone creates a file named
"/tmp/foo
/etc/passwd
bar.log"
and a careless system person runs a script as root to remove all files
named *.log from /tmp/ and subdirectories.
find /tmp -name '*.log' -print | xargs rm
is an insanely reckless way to do it, which in this case would cause the
removal of the password file. Much better:
find /tmp -name '*.log' -type f -print0 | xargs -0 rm
or even better:
find /tmp -name '*.log' -type f -exec rm {} +
In summary, if you have to encode a list of filenames in a byte stream,
doing it with zero terminated is the correct way to do it.
? Harald
------------------------------
Message: 6
Date: Sun, 11 Oct 2015 11:33:50 +0200
From: Imants Cekusins <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Reading a list of null-terminated
filenames from stdin?
Message-ID:
<CAP1qinZf4a_CHW2+3RKhnqcnK2=7qd9x5kacvww0f2njzk7...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8
why not base64 encode input text to produce file names:
https://en.wikipedia.org/wiki/Base64#Filenames
The encoded file names would be less likely to cause problem. You
could get the original text input by decoding the file name.
------------------------------
Message: 7
Date: Sun, 11 Oct 2015 11:38:11 +0200
From: Harald Hanche-Olsen <[email protected]>
To: haskell-beginners <[email protected]>
Subject: Re: [Haskell-beginners] Reading a list of null-terminated
filenames from stdin?
Message-ID: <[email protected]>
Content-Type: text/plain; charset=windows-1252; format=flowed
Imants Cekusins wrote:
> why not base64 encode input text to produce file names:
>
> https://en.wikipedia.org/wiki/Base64#Filenames
An intriguing idea, but sometimes you just have to accept what the
upstream program provides.
? Harald
------------------------------
Message: 8
Date: Sun, 11 Oct 2015 12:45:23 +0300
From: Michael Snoyman <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Reading a list of null-terminated
filenames from stdin?
Message-ID:
<CAKA2JgJAmvzmr8wYXngGFterea0E5ehMNgwfjwCBF=b7l53...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On Sat, Oct 10, 2015 at 9:45 PM, Dan Stromberg <[email protected]> wrote:
>
> If I want to read a list of filenames, each terminated with a nul byte,
> from stdin (kind of like xargs -0), what's the best way to do that in
> Haskell? Or am I swimming against the current to do anything but
> newline-termination?
>
> Google's top hit is:
>
> https://downloads.haskell.org/~ghc/7.6.1/docs/html/libraries/bytestring-0.10.0.0/Data-ByteString.html
> ...but I don't see anything about nul termination there. I checked the
> top ~5 hits, and didn't find much.
>
> I also checked https://www.haskell.org/hoogle/?hoogle=Lines
>
> The goal is to be able to operate on filenames that contain newlines, but
> it's not that end of the world if that isn't very practical.
>
> Thanks!
>
> --
> Dan Stromberg
>
>
>
To give you an idea of how this might be done, I put together an example
using the conduit-combinators library:
https://gist.github.com/snoyberg/2a5ca79d97f483bdcfe9
This can be done in a more low-level manner by using the bytestring library
directly, which will require learning less new concepts. However, streaming
libraries like conduit and pipes are specifically designed for handling
these kinds of problems. There's a tutorial on conduit available at:
https://github.com/snoyberg/conduit#readme
Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20151011/92b9db1f/attachment.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 88, Issue 8
****************************************