Bug 211579 - Remove socket support in cat(1)
Summary: Remove socket support in cat(1)
Status: Closed Not Accepted
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 11.0-BETA3
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs mailing list
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2016-08-04 14:08 UTC by Sevan Janiyan
Modified: 2016-08-05 23:09 UTC (History)
2 users (show)

See Also:


Attachments
No socket (4.69 KB, patch)
2016-08-04 14:08 UTC, Sevan Janiyan
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sevan Janiyan 2016-08-04 14:08:54 UTC
Created attachment 173280 [details]
No socket

This feature was added to cat(1) to complement inetd's ability to listen on a UNIX domain socket but the feature seems out of place for a utility that is intended to concatenate files and better served by other tools such as netcat perhaps.

Attached patch removes the support which was introduced in r83482.
Comment 1 Maxim Konovalov freebsd_committer 2016-08-04 14:24:43 UTC
> This feature was added to cat(1) to complement inetd's ability to listen on a > UNIX domain socket [..]

Is it really correct?  I think it is just a handy way to work with unix sockets from command line.

> Attached patch removes the support which was introduced in r83482.

What's the reason?  How does it hurt?

Should we also remove "telnet -u"?
Comment 2 Sevan Janiyan 2016-08-04 14:44:29 UTC
(In reply to Maxim Konovalov from comment #1)

> Is it really correct?  I think it is just a handy way to work with unix sockets from command line.

The svn history confirms it, see r83482.

> What's the reason?  How does it hurt?

As I said, the feature seems out of place for a utility that is intended to concatenate files and better served by other tools such as netcat perhaps.
Comment 3 Maxim Konovalov freebsd_committer 2016-08-04 14:53:36 UTC
(In reply to Sevan Janiyan from comment #2)

In https://svnweb.freebsd.org/base?view=revision&revision=83482 I see nothing about inetd(8).

This feature was committed 15 years ago and since than nobody complained.  

There is a non-zero probability that people are using this particular feature in their scripts and removing it will break backward compatibility with no particular reason.

Unix world utilities historically have a lot of overlapping functionality.  So far it works more or less ok.

Also

> a utility that is intended to concatenate files 

But unix socket is a file.
Comment 4 Sevan Janiyan 2016-08-04 15:27:58 UTC
(In reply to Maxim Konovalov from comment #3)

Apologies, it's in the addition to cat.1 introduced in r83482, not in the commit message itself.

> There is a non-zero probability that people are using this particular feature in their scripts and removing it will break backward compatibility with no particular reason.

I would argue that seeing as a major branch is about it be cut, now would be the time to evaluate such a change, it would be quite some time before it made it into a major release and would fish out some active participants who are users of the feature.
Comment 5 John Baldwin freebsd_committer freebsd_triage 2016-08-04 17:26:17 UTC
While 'nc' would seem to the obvious replacement, I haven't yet found a way to get equivalent functionality.  I use 'nc -kU -l /tmp/sock' to create a socket.  I can then type into that terminal to store data in netcat's "buffer".  'cat /tmp/sock' drains whatever data is pending and exits.  'nc -dNU /tmp/sock' comes close to this except that it will still block if there is no pending data instead of exiting with null output.  Also, given that existing scripts, etc. might depend on this feature of cat (given it's been present for so long), it seems best to just leave well enough alone in this case.