Subject: [PATCH sxmo-utils v5 1/8] Do not prevent interactive editors to write messages

From: Reed Wade <[email-masked]>
Date: Sat, 10 Oct 2020 15:59:28 +0200

We run EDITOR in a subshell and that prevent some editors as kakoune :

Fatal error: stdout is not a tty

This refactorise a little bit editmsg logic to not run EDITOR in a
subshell and allow those editors to work.

Signed-off-by: Reed Wade <[email-masked]>
---
 scripts/modem/sxmo_modemtext.sh | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Rebased works. I expect it to be mergeable now !

diff --git a/scripts/modem/sxmo_modemtext.sh b/scripts/modem/sxmo_modemtext.sh
index 61ca43d..2551dec 100755
--- a/scripts/modem/sxmo_modemtext.sh
+++ b/scripts/modem/sxmo_modemtext.sh
@@ -22,14 +22,12 @@ modem_n() {
 }

 editmsg() {
-	TMP="$(mktemp --suffix "$1_msg")"
-	echo "$2" > "$TMP"
+	TMP="$1"
 	if [ "$TERMMODE" != "true" ]; then
 		st -e "$EDITOR" "$TMP"
 	else
 		"$EDITOR" "$TMP"
 	fi
-	cat "$TMP"
 }

 sendtextmenu() {
@@ -47,7 +45,10 @@ sendtextmenu() {
 	echo "$NUMBER" | grep -qE '^[+0-9]+$' || err "That doesn't seem like a valid number"

 	# Compose first version of msg
-	TEXT="$(editmsg "$NUMBER" 'Enter text message here')"
+	TMP="$(mktemp --suffix "${NUMBER}_msg")"
+	echo 'Enter text message here' > "$TMP"
+	editmsg "$TMP"
+	TEXT="$(cat "$TMP")"

 	while true
 	do
@@ -57,7 +58,7 @@ sendtextmenu() {
 		)"
 		echo "$CONFIRM" | grep -E "^Send" && (echo "$TEXT" | sxmo_modemsendsms.sh "$NUMBER" -) && exit 0
 		echo "$CONFIRM" | grep -E "^Cancel$" && exit 1
-		echo "$CONFIRM" | grep -E "^Edit Message" && TEXT="$(editmsg "$NUMBER" "$TEXT")"
+		echo "$CONFIRM" | grep -E "^Edit Message" && editmsg "$TMP" && TEXT="$(cat "$TMP")"
 	done
 }

--
2.28.0

---

From: Kevin Daudt <[email-masked]>
Date: Sat, 10 Oct 2020 18:56:50 +0200

> +		echo "$CONFIRM" | grep -E "^Edit Message" && editmsg "$TMP" && TEXT="$(cat "$TMP")"

I think you send this to the wrong mailing list. This does not seem to
have anything to do with Alpine Linux aports.

Kevin

---

From: ReedWade <[email-masked]>
Date: Mon, 12 Oct 2020 09:25:34 +0200

Oh got, I'm so sorry for this spam :O

I messed-up with my Ctrl-R and used the wrong command.
Let's never do it again.

---

From: Reed Wade <[email-masked]>
Date: Sat, 10 Oct 2020 15:59:34 +0200

Signed-off-by: Reed Wade <[email-masked]>
---
 scripts/appscripts/sxmo_files.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/appscripts/sxmo_files.sh b/scripts/appscripts/sxmo_files.sh
index 280f4b9..6cc9e0f 100755
--- a/scripts/appscripts/sxmo_files.sh
+++ b/scripts/appscripts/sxmo_files.sh
@@ -9,7 +9,7 @@ handlefiles() {
 	elif echo "$1" | grep -iE ".(wav|opus|m4a|flac|mp3)$"; then
 		st -e mpv -ao=alsa --vid=no -v "$@"
 	elif echo "$1" | grep -iE ".(jpg|png|gif)$"; then
-		st -e sxiv "$@"
+		st -e mpv --profile=image "$@"
 	else
 		st -e sh -ic "$EDITOR $*"
 	fi
-- 
2.28.0