Live data from Hacker News

Simple Unix Chat

the-dam.org

171–175 of 175 posts

Re: Simple Unix Chat

#171
post #148
post #134

Earlier quoted context omitted.

It isn't what I think it is? Oh. Then it must be: command ls -F directory | grep -v '[/@]$' | nl | tail -n 1 | cut -f 1 (-:

This doesn't work. Try setting up a folder as follows: touch first$'\n'file touch .hidden$'\n'file mkdir folder$'\n'. touch folder$'\n'./another$'\n'file mkdir normal touch normal/whatever This folder has two files in it, or four if you count files in subdirectories. Your solution incorrectly outputs 3.

As clearly stated, the above is not what I think the way to do it is.

Re: Simple Unix Chat

#172
post #51

> suc does all that by leveraging SSH, UNIX’s access control API, and UNIX’s text-based modularity. On any fair metric, this should inflate the volume of code metric for any project (whether leveraging those APIs directly or not). It would still favor this implementation on that front, and there are still other merits to the approach besides code volume. But something does irk me about touting supposed minimalism whi…

By that argument, you should count the codebase of the whole browser against slack.

I definitely do

Re: Simple Unix Chat

#173
UNIX shell is good like that, that you can combine thing in shell scripts and command-line you can make such a combined program, if you are using programs that are designed to support that (unfortunately, too many modern programs don't, although some do).

However, is there a race condition with writing to the files? Since it is append mode, I would expect that would prevent other processes overwriting the file, although would it prevent other processes writing in the middle of a line if it gets interrupted? Actually, I don't know.

I had made a simple two user chat system with logging using ts, tee, and nc; using a shell script with only a single line of code. This produces two log files, one for sending and one for receiving; however, I can then use cat and sort to interleave the logs into a single log file.

Re: Simple Unix Chat

#174
post #113

Earlier quoted context omitted.

OK, for starter the while loop. Main rule of writing shell scripts is, Use The Shell, Luke. Don't start external programs, if your shell (which is already running) can do it. "while /usr/bin/true" is nonsense, every time an external program gets executed for nothing. There are plenty of bash (since this shell is used in the example) internals, which evaluate to true, like ":", "test 1", "(( 1 ))", maybe others too. S…

Thanks for the pointer about the useless use of true. Using builtins may be a security risk as they can be overloaded (hence the use of full paths everywhere). I did not know about bash's extension of printf to print a date. I need to use the builtin to use it though. But I've received good advice elsewhere on how to do that securely, so I'll do it and do a write-up because it's not information that's easy to come by…

Bash and zsh both allow:

  function /usr/bin/cat { echo hello; }; 
  /usr/bin/cat
  hello
So specifying a path isn't as useful as it seems

Re: Simple Unix Chat

#175

In case you're passing over this because it sounds like click bait (it KIND OF is), this was actually a good read to me. It goes over a utility called "suc" (Simple Unix Chat) that implements server functionalities from Slack, Discord, etc. using a very small codebase. The novel part is it leverages existing unix tools and methodology instead of re-inventing them. - Auth is handled by SSH. - Channels are just a file…

> re-inventing them

Existing chat platforms don't "re-invent" Unix tools - they're simply not suitable for building on top of. There's a reason that approximately 0 large production systems are written in shell script using the "everything is a file" paradigm - because it's not acceptable for any non-trivial system that needs to see real-world use.

Post reply on HN