#! while read -r line; do # Extremely long regex for validating RFC 3339 timestamps # Blame the POSIX ERE specification for the [0-9]s. timestamp=$(echo "$line" | grep -Eo '^[0-9]{4}-[01][0-9]-[0-3][0-9][Tt][0-2][0-9]:[0-5][0-9]:[0-5][0-9](\.[0-9]+)?([+-][0-2][0-9]:[0-5][0-9]|Zz)') # This sed command tries to sanitize twts # Backslashes are mangled because of piping echo, there's no <<< allowed. > # Could potentially be solved by using a temp file twt=$(echo "$line" | sed -e 's/"/\"/g; s/`/\`/g' | cut -f 2- -) # This sed command is awful, but it has to be this way because only BREs are allowed in sed. # It may be worth it to pipe grep into sed here to use grep's EREs, especially if extending to gopher:// and gemini:// hyperlinked=$(echo "$twt" | sed 's|http://[^ ]*[^ ,.;:)>}!]|&|g; s|https://[^ ]*[^ ,.;:)>}!]|&|g') #!
  • ${timestamp}
    ${hyperlinked}
  • #! done #!