From 9f8b5e00306615038069f5f31c8082eeb695fb54 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 4 Sep 2016 19:01:57 +0100 Subject: [PATCH] Better handling of users file --- src/freedombone-mesh-visit-site | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/freedombone-mesh-visit-site b/src/freedombone-mesh-visit-site index a23bb645..4c5e7b23 100755 --- a/src/freedombone-mesh-visit-site +++ b/src/freedombone-mesh-visit-site @@ -61,15 +61,17 @@ case $sel in --msgbox $"The user '$TOX_USERNAME' was not found on the mesh" 8 60 exit 2 fi - TOX_ID=$(cat "$USERS_FILE" | grep "$TOX_USERNAME" | head -n 1 | awk -F ' ' '{print $2}') - if ! grep -q "$TOX_ID" $IPFS_USERS_FILE; then - dialog --title $"Visit IPFS site" \ - --backtitle $"Freedombone mesh" \ - --msgbox $"An IPFS site was not found for the user '$TOX_USERNAME'" 8 60 - exit 3 + TOX_ID=$(cat "$USERS_FILE" | grep "$TOX_USERNAME" | head -n 1 | sed "s|$TOX_USERNAME ||g" | sed -e 's/^[[:space:]]*//') + if [ ${#TOX_ID} -gt 5 ]; then + if ! grep -q "$TOX_ID" $IPFS_USERS_FILE; then + dialog --title $"Visit IPFS site" \ + --backtitle $"Freedombone mesh" \ + --msgbox $"An IPFS site was not found for the user '$TOX_USERNAME'" 8 60 + exit 3 + fi + IPFS_FULL_URL=${IPFS_URL}/$(cat "$IPFS_USERS_FILE" | grep $TOX_ID | head -n 1 | awk -F ':' '{print $2}') + $BROWSER $IPFS_FULL_URL fi - IPFS_FULL_URL=${IPFS_URL}/$(cat "$IPFS_USERS_FILE" | grep $TOX_ID | head -n 1 | awk -F ':' '{print $2}') - $BROWSER $IPFS_FULL_URL else exit 1 fi