Last active
February 15, 2022 21:44
-
-
Save jeroenjanssens/7896821 to your computer and use it in GitHub Desktop.
Simple chat server in bash, demonstrating websocketd.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Hacked together by JeroenJanssens.com on 2013-12-10 | |
# Requires: https://github.com/joewalnes/websocketd | |
# Run: websocketd --devconsole --port 8080 ./chat.sh | |
echo "Please enter your name:"; read USER | |
echo "[$(date)] ${USER} joined the chat" >> chat.log | |
echo "[$(date)] Welcome to the chat ${USER}!" | |
tail -n 0 -f chat.log --pid=$$ | grep --line-buffered -v "] ${USER}>" & | |
while read MSG; do echo "[$(date)] ${USER}> ${MSG}" >> chat.log; done |
yeah, I just tested it out to see if my comment was even correct and it is not. It's properly escaped. Now I'm trying to figure out how it's properly escaped without performing the typical filter which in this case would be: USER=${USER//[^a-zA-Z0-9_]/} as well as MSG=${MSG//^a-zA-Z0-9_]/}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I just checked and backticks are actually escaped properly. But please keep in mind that this is just a toy example. :-)