The Arch provided languagetool.sh wrapper prevents reading input from stdin
Description:
The upstream projects list the ability to read input from stdin [1] by specifying -
as the input filename. However, the wrapper script languagetool.sh
provided by Arch(?) prevents this behavior.
The issue how the script examines the arguments passed to it to judge if the GUI or CLI application should be used based on if the last argumet starts with a -
, or not. A possible fix for this issues is,
From 6116fccf112be2c38e70c7e4c4edf66025b9811a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>
Date: Mon, 19 Feb 2024 23:34:31 +0100
Subject: [PATCH] Allow input from stdin
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Adapt wrapper script to allow reading input from stdin by treating a
single - as a filename. This behaviour is document upstream [1].
1. https://dev.languagetool.org/tips-and-tricks.html#checking-text-from-standard-input
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
---
languagetool.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/languagetool.sh b/languagetool.sh
index d5003eeb2319..2b5d3884d553 100755
--- a/languagetool.sh
+++ b/languagetool.sh
@@ -10,7 +10,7 @@ declare -a argv=("$@")
i=0
for arg in "$@"; do
- if [[ $arg != -* ]]; then
+ if [[ $arg != -* || $arg == - ]]; then
file_present=true
fi
if [[ $arg == --config* ]]; then
--
2.43.0
Additional info:
- package version(s): 6.3.a-1
- config and/or log files:
- link to upstream bug report, if any:
Steps to reproduce:
Without a fix
$ cat test
This is a example input to to show you how LanguageTool works.
$ cat test | ./languagetool.sh -adl -
Usage: java org.languagetool.gui.Main [-t|--tray]
or java org.languagetool.gui.Main [file]
Parameters:
-t, --tray: dock LanguageTool to system tray on startup
file: a plain text file to load on startup
The GUI application is started but don't know what to do about the arguments.
With the fix applied
$ cat test
This is a example input to to show you how LanguageTool works.
$ cat test | ./languagetool.sh -adl -
Working on STDIN...
WARN: no common words file defined for Japanese - this language might not be correctly auto-detected
WARN: no common words file defined for Khmer - this language might not be correctly auto-detected
Using English for file -
1.) Line 1, column 9, Rule ID: EN_A_VS_AN premium: false prio=-1
Message: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Suggestion: an
This is a example input to to show you how LanguageToo...
^
More info: https://languagetool.org/insights/post/indefinite-articles/
2.) Line 1, column 25, Rule ID: ENGLISH_WORD_REPEAT_RULE premium: false prio=-1
Message: Possible typo: you repeated a word
Suggestion: to
This is a example input to to show you how LanguageTool works.
^^^^^
Time: 560ms for 1 sentences (1.8 sentences/sec)
The CLI application is started and do the work.