diff --git a/Makefile.in b/Makefile.in index 10607c6..fe474dc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -340,6 +340,7 @@ STRIP = @STRIP@ UNZIP = @UNZIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ +WHICH = @WHICH@ WISH = @WISH@ XDG_OPEN = @XDG_OPEN@ XGETTEXT = @XGETTEXT@ diff --git a/configure b/configure index 831c6d9..bb06881 100755 --- a/configure +++ b/configure @@ -649,6 +649,7 @@ LIBOBJS ENABLE_COMPLETION_FALSE ENABLE_COMPLETION_TRUE SDL2_CONFIG +WHICH WISH COMPLETION_DIR PKG_CONFIG @@ -8104,6 +8105,64 @@ if test "$WISH" = "no" ; then exit 1; fi +for ac_prog in which +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_path_WHICH+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) case $WHICH in + [\\/]* | ?:[\\/]*) + ac_cv_path_WHICH="$WHICH" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_path_WHICH="$as_dir$ac_word$ac_exec_ext" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac ;; +esac +fi +WHICH=$ac_cv_path_WHICH +if test -n "$WHICH"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $WHICH" >&5 +printf "%s\n" "$WHICH" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + + test -n "$WHICH" && break +done +test -n "$WHICH" || WHICH="no" + + +if test "$WHICH" = "no" ; then + as_fn_error $? "Can not find which executable." "$LINENO" 5 + exit 1; +fi + for ac_prog in sdl2-config do # Extract the first word of "$ac_prog", so it can be a program name with args. diff --git a/configure.ac b/configure.ac index 5fe8fff..0522c41 100644 --- a/configure.ac +++ b/configure.ac @@ -161,6 +161,13 @@ if test "$WISH" = "no" ; then exit 1; fi +AC_PATH_PROGS([WHICH],[which],[no]) + +if test "$WHICH" = "no" ; then + AC_MSG_ERROR([Can not find which executable.]) + exit 1; +fi + AC_PATH_PROGS([SDL2_CONFIG],[sdl2-config],[no]) if test "$SDL2_CONFIG" = "no" ; then diff --git a/po/ca.po b/po/ca.po index debfdd7..3892b9b 100644 --- a/po/ca.po +++ b/po/ca.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: tinmop 0.9.9.1414213562-rc1\n" "Report-Msgid-Bugs-To: https://codeberg.org/cage/tinmop/\n" -"POT-Creation-Date: 2024-12-13 14:41+0100\n" +"POT-Creation-Date: 2024-12-15 17:20+0100\n" "PO-Revision-Date: 2024-05-25 13:29+0200\n" "Last-Translator: Eloitor \n" "Language-Team: Catalan \n" "Language-Team: German \n" "Language-Team: Italian \n" @@ -1057,7 +1057,13 @@ msgstr "" "Un file con lo stesso nome esiste già nella tua libreria, vuoi " "sovrascriverlo?" -#: src/gui/client/os-utils.lisp:41 src/os-utils.lisp:274 +#: src/gui/client/os-utils.lisp:37 +#, lisp-format +msgid "external program ~a not found, check your configuration file." +msgstr "" +"Programma esterno: ~a non trovato, controlla i tuoi file di configurazione." + +#: src/gui/client/os-utils.lisp:50 src/os-utils.lisp:284 msgid "No program defined in configuration file to edit this kind of files" msgstr "" "Nessun programma è stato definito nel file di configurazione per modificare " @@ -1564,22 +1570,22 @@ msgstr "Carica: " msgid "Chat attachments" msgstr "Allegati alla chat" -#: src/os-utils.lisp:300 src/ui-goodies.lisp:1243 +#: src/os-utils.lisp:310 src/ui-goodies.lisp:1243 #, lisp-format msgid "File ~s does not exists" msgstr "Il file ~s non esiste" -#: src/os-utils.lisp:302 +#: src/os-utils.lisp:312 #, lisp-format msgid "Destination directory ~s does not exists" msgstr "La directory di destinazione ~s non esiste" -#: src/os-utils.lisp:320 +#: src/os-utils.lisp:330 #, lisp-format msgid "File ~s extraction from ~s failed" msgstr "File ~s estrazione da ~s fallita" -#: src/os-utils.lisp:338 +#: src/os-utils.lisp:348 #, lisp-format msgid "Compressing directory ~s failed" msgstr "Compressione della directory ~s fallita" diff --git a/po/pl.po b/po/pl.po index fe69598..9ea13aa 100644 --- a/po/pl.po +++ b/po/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: tinmop 0.9.9.1414\n" "Report-Msgid-Bugs-To: https://codeberg.org/cage/tinmop/\n" -"POT-Creation-Date: 2024-12-13 14:41+0100\n" +"POT-Creation-Date: 2024-12-15 17:20+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Automatically generated\n" "Language-Team: none\n" @@ -1036,7 +1036,12 @@ msgstr "" msgid "A file with this name exists in your library: overwrite?" msgstr "" -#: src/gui/client/os-utils.lisp:41 src/os-utils.lisp:274 +#: src/gui/client/os-utils.lisp:37 +#, lisp-format +msgid "external program ~a not found, check your configuration file." +msgstr "" + +#: src/gui/client/os-utils.lisp:50 src/os-utils.lisp:284 msgid "No program defined in configuration file to edit this kind of files" msgstr "" @@ -1524,22 +1529,22 @@ msgstr "" msgid "Chat attachments" msgstr "" -#: src/os-utils.lisp:300 src/ui-goodies.lisp:1243 +#: src/os-utils.lisp:310 src/ui-goodies.lisp:1243 #, lisp-format msgid "File ~s does not exists" msgstr "" -#: src/os-utils.lisp:302 +#: src/os-utils.lisp:312 #, lisp-format msgid "Destination directory ~s does not exists" msgstr "" -#: src/os-utils.lisp:320 +#: src/os-utils.lisp:330 #, lisp-format msgid "File ~s extraction from ~s failed" msgstr "" -#: src/os-utils.lisp:338 +#: src/os-utils.lisp:348 #, lisp-format msgid "Compressing directory ~s failed" msgstr "" diff --git a/po/tinmop.pot b/po/tinmop.pot index 232455e..17f9a6d 100644 --- a/po/tinmop.pot +++ b/po/tinmop.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: tinmop 0.9.9.1414213562373\n" "Report-Msgid-Bugs-To: https://codeberg.org/cage/tinmop/\n" -"POT-Creation-Date: 2024-12-13 14:41+0100\n" +"POT-Creation-Date: 2024-12-15 17:20+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1035,7 +1035,12 @@ msgstr "" msgid "A file with this name exists in your library: overwrite?" msgstr "" -#: src/gui/client/os-utils.lisp:41 src/os-utils.lisp:274 +#: src/gui/client/os-utils.lisp:37 +#, lisp-format +msgid "external program ~a not found, check your configuration file." +msgstr "" + +#: src/gui/client/os-utils.lisp:50 src/os-utils.lisp:284 msgid "No program defined in configuration file to edit this kind of files" msgstr "" @@ -1523,22 +1528,22 @@ msgstr "" msgid "Chat attachments" msgstr "" -#: src/os-utils.lisp:300 src/ui-goodies.lisp:1243 +#: src/os-utils.lisp:310 src/ui-goodies.lisp:1243 #, lisp-format msgid "File ~s does not exists" msgstr "" -#: src/os-utils.lisp:302 +#: src/os-utils.lisp:312 #, lisp-format msgid "Destination directory ~s does not exists" msgstr "" -#: src/os-utils.lisp:320 +#: src/os-utils.lisp:330 #, lisp-format msgid "File ~s extraction from ~s failed" msgstr "" -#: src/os-utils.lisp:338 +#: src/os-utils.lisp:348 #, lisp-format msgid "Compressing directory ~s failed" msgstr "" diff --git a/src/gui/client/os-utils.lisp b/src/gui/client/os-utils.lisp index ac14fc3..fd69760 100644 --- a/src/gui/client/os-utils.lisp +++ b/src/gui/client/os-utils.lisp @@ -19,7 +19,6 @@ (defun open-resource-with-external-program (main-window resource &key (open-for-edit nil)) (gui-goodies:with-notify-errors (flet ((edit (file) - (croatoan:end-screen) (os-utils:open-with-editor file))) (alexandria::when-let* ((parsed-as-iri (iri:iri-parse resource :null-on-error t)) (parsed-no-fragment (iri:remove-fragment parsed-as-iri))) @@ -28,6 +27,15 @@ (swconf:link-regex->program-to-use resource)))) (if program (cond + ((not (os-utils:executable-exists-p program)) + ;; this branch is a workaround. + ;; os-utils:open-link-with-program should signal an + ;; error when a program is not found but, fore some + ;; reason, it will crash the software; even wrapping + ;; the call to 'os-utils:open-link-with-program' with + ;; 'ignore-errors' does not works + (error (_ "external program ~a not found, check your configuration file.") + program)) ((swconf:use-editor-as-external-program-p program) (edit resource)) ((swconf:use-tinmop-as-external-program-p program) diff --git a/src/os-utils.lisp b/src/os-utils.lisp index b28e4bf..034b9b6 100644 --- a/src/os-utils.lisp +++ b/src/os-utils.lisp @@ -165,6 +165,16 @@ numerical user ID, as an assoc-list." :output t :error t)))) +(defun executable-exists-p (name) + (text-utils:string-not-empty-p + (ignore-errors + (text-utils:trim-blanks (with-output-to-string (stream) + (uiop:wait-process (uiop:launch-program (list "which" + name) + :input nil + :output stream + :error-output nil))))))) + (defun exit-program (&optional (exit-code 0)) (uiop:quit exit-code)) diff --git a/src/package.lisp b/src/package.lisp index 703f880..a971b21 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -424,6 +424,7 @@ :process-input :process-output :open-with-editor + :executable-exists-p :exit-program :user-cache-dir :cached-file-path