Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions mannaggia.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,18 @@ DELSTRING1="</FONT>"
DELSTRING2="</b>"
DEFPLAYER="mplayer -really-quiet -ao alsa"
PLAYER="${PLAYER:-$DEFPLAYER}"

notify=0
help=0
# lettura parametri da riga comando
for parm in "$@"
do
if [ "$parm" = "--help" ];then
help=1
fi
if [ "$parm" = "--notify" ]
then
notify=1
fi
# leggi dai parametri se c'e' l'audio
if [ "$parm" = "--audio" ]
then
Expand All @@ -44,7 +52,7 @@ for parm in "$@"

# leggi dai parametri se c'e' da mandare i commenti su wall
if [ "$parm" = "--wall" ]
then
then
wallflag=true
fi

Expand Down Expand Up @@ -90,7 +98,7 @@ while [ "$nds" != 0 ]
# shellcheck disable=SC2019
MANNAGGIA="Mannaggia $(curl -s "www.santiebeati.it/$(</dev/urandom tr -dc A-Z|head -c1)/"|grep -a tit|cut -d'>' -f 4-9|shuf -n1 |awk -F "$DELSTRING1" '{print$1$2}'|awk -F "$DELSTRING2" '{print$1}')"
MANNAGGIAURL="http://www.ispeech.org/p/generic/getaudio?text=$MANNAGGIA%2C&voice=euritalianmale&speed=0&action=convert"

if [ "$wallflag" = true ]
then
pot=$(( nds % 50 ))
Expand All @@ -101,7 +109,20 @@ while [ "$nds" != 0 ]
# attenzione: se non siete root o sudoers dovete togliere dalla riga successiva "sudo" e "-n"
echo "$MANNAGGIA" | sudo wall -n
fi
#mannaggia via notifica desktop
elif [ "$notify" = 1 ]; then
if ( ! type "notify-send" >/dev/null 2>&1 ); then
echo "Ti serve notify-send"
exit 1
else
notify-send "$MANNAGGIA" 2>/dev/null
fi
elif [ "$help" = 1 ]; then
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Da un punto di vista puramente logico, se l'utente chiede l'help ogni azione dovrebbe essere soppressa, quindi il check dovrebbe essere in cima

echo "Uso: ./mannaggiatore.sh [opzioni]\nQuesto script provvede a nominare tutti i santi per voi quando vi sentite depressi.\n\nOpizoni:\n --audio: attiva mplayer per fargli pronunciare i santi
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Diversi problemi:

  • nome dello script hardcodato (trivial)
  • SC2028: echo won't expand escape sequences. Consider printf. (critical)
  • mplayer non è necessariamente il player di default (minor)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per quanto riguarda l'usage, ho preso le descrizioni che avete dato voi alle opzioni
Provvederò al più preso a sostituire echo con printf

--spm: numero di santi per minuto\n --wall: invia l'output a tute le console: atenzione, se non siete root o sudoers disattivare il flag -n\n --notify: invia una notifica desktop\n --help: mostra questa pagina\n\n Buona managgiata a tutti e ricordate: $MANNAGGIA systemd merda 0/"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/atenzione/attenzione/

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refuso

exit 0

else
echo "$MANNAGGIA" > /dev/stdout
fi

Expand Down