From 92b9476c870c9b59e69f0ec6e74748140b8da139 Mon Sep 17 00:00:00 2001 From: Jaidyn Ann <10477760+JadedCtrl@users.noreply.github.com> Date: Sun, 6 Aug 2023 23:00:07 -0500 Subject: [PATCH] Fix making posts sans media --- fedi-post.sh | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/fedi-post.sh b/fedi-post.sh index ff248d5..18efaee 100644 --- a/fedi-post.sh +++ b/fedi-post.sh @@ -23,9 +23,8 @@ file_status() { local file="$1" local id="$(head -1 "$file" | awk '{print $3}')" local url="$(head -1 "$file" | awk '{print $4}')" - tail +4 "$file" \ - | sanitize_text \ - | grep -v "$id" + tail +2 "$file" \ + | sanitize_text if test -n "$url"; then printf '
[Originala afiŝo]\\n' "$url" fi @@ -35,12 +34,16 @@ file_status() { # Turns a space-delimited list of uploaded media-IDs into a JSON array. media_json() { local ids="$1" - echo "$ids" \ - | sed 's%^ %%' \ - | sed 's% $%%' \ - | sed 's%^%["%' \ - | sed 's% %","%g' \ - | sed 's%$%"]%' + if test -n "$ids"; then + echo "$ids" \ + | sed 's%^ %%' \ + | sed 's% $%%' \ + | sed 's%^%["%' \ + | sed 's% %","%g' \ + | sed 's%$%"]%' + else + echo "" + fi }