2020-09-09 09:50:47 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
2020-06-13 13:45:23 +01:00
|
|
|
editScript="$1"
|
|
|
|
|
if [ ${#editScript} -eq 0 ]; then
|
|
|
|
|
echo "please specify a file to the edit"
|
|
|
|
|
else
|
|
|
|
|
echo "Opening $editScript"
|
|
|
|
|
fi
|
|
|
|
|
# temp conf
|
2020-09-09 09:50:47 +01:00
|
|
|
conf=$(mktemp 2>/dev/null)
|
2020-06-13 13:45:23 +01:00
|
|
|
# trap it
|
2020-09-09 09:50:47 +01:00
|
|
|
trap 'rm -f $conf' 0 1 2 5 15
|
2020-06-13 13:45:23 +01:00
|
|
|
dialog \
|
|
|
|
|
--title "Editing the $editScript" \
|
2020-09-09 09:50:47 +01:00
|
|
|
--editbox "$editScript" 200 200 2> "$conf"
|
2020-06-13 13:45:23 +01:00
|
|
|
# make decison
|
|
|
|
|
pressed=$?
|
|
|
|
|
case $pressed in
|
|
|
|
|
0)
|
2020-06-16 15:27:15 +01:00
|
|
|
dialog --title "Finished editing" \
|
|
|
|
|
--msgbox "
|
|
|
|
|
Saving to:
|
|
|
|
|
$editScript" 7 56
|
2020-09-09 09:50:47 +01:00
|
|
|
sudo -u joinmarket tee "$editScript" 1>/dev/null < "$conf"
|
|
|
|
|
shred "$conf";;
|
2020-06-13 13:45:23 +01:00
|
|
|
1)
|
2020-09-09 09:50:47 +01:00
|
|
|
shred "$conf"
|
2020-06-16 15:27:15 +01:00
|
|
|
DIALOGRC=.dialogrc.onerror dialog --title "Finished editing" \
|
|
|
|
|
--msgbox "
|
|
|
|
|
Cancelled editing:
|
|
|
|
|
$editScript" 7 56
|
2020-06-13 13:45:23 +01:00
|
|
|
echo "Cancelled"
|
|
|
|
|
exit 0;;
|
|
|
|
|
255)
|
2020-09-09 09:50:47 +01:00
|
|
|
shred "$conf"
|
|
|
|
|
[ -s "$conf" ] && cat "$conf" || echo "ESC pressed."
|
2020-06-13 13:45:23 +01:00
|
|
|
exit 0;;
|
|
|
|
|
esac
|