From 19b62a6776e4e7820036919fddd4ce918085a358 Mon Sep 17 00:00:00 2001 From: toonn Date: Tue, 9 Oct 2018 15:19:41 +0200 Subject: Add double quotes SC2086 --- ranger/data/scope.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh index 9202146d..5a0ece2b 100755 --- a/ranger/data/scope.sh +++ b/ranger/data/scope.sh @@ -61,8 +61,8 @@ handle_extension() { # PDF pdf) # Preview as text conversion - pdftotext -l 10 -nopgbrk -q -- "${FILE_PATH}" - | fmt -w ${PV_WIDTH} && exit 5 - mutool draw -F txt -i -- "${FILE_PATH}" 1-10 | fmt -w ${PV_WIDTH} && exit 5 + pdftotext -l 10 -nopgbrk -q -- "${FILE_PATH}" - | fmt -w "${PV_WIDTH}" && exit 5 + mutool draw -F txt -i -- "${FILE_PATH}" 1-10 | fmt -w "${PV_WIDTH}" && exit 5 exiftool "${FILE_PATH}" && exit 5 exit 1;; -- cgit 1.4.1-2-gfad0 From 429003ff268887c39eb73a15aa19dc400c8a11c4 Mon Sep 17 00:00:00 2001 From: toonn Date: Tue, 9 Oct 2018 15:30:05 +0200 Subject: Double up comment characters for comments To make it easy to automatically strip comments from sections of code I doubled up the comment characters for actual comments. This works for everything but the shebang line. --- ranger/data/scope.sh | 117 ++++++++++++++++++++++++++------------------------- 1 file changed, 59 insertions(+), 58 deletions(-) diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh index 5a0ece2b..9dad8609 100755 --- a/ranger/data/scope.sh +++ b/ranger/data/scope.sh @@ -3,27 +3,27 @@ set -o noclobber -o noglob -o nounset -o pipefail IFS=$'\n' -# If the option `use_preview_script` is set to `true`, -# then this script will be called and its output will be displayed in ranger. -# ANSI color codes are supported. -# STDIN is disabled, so interactive scripts won't work properly - -# This script is considered a configuration file and must be updated manually. -# It will be left untouched if you upgrade ranger. - -# Meanings of exit codes: -# code | meaning | action of ranger -# -----+------------+------------------------------------------- -# 0 | success | Display stdout as preview -# 1 | no preview | Display no preview at all -# 2 | plain text | Display the plain content of the file -# 3 | fix width | Don't reload when width changes -# 4 | fix height | Don't reload when height changes -# 5 | fix both | Don't ever reload -# 6 | image | Display the image `$IMAGE_CACHE_PATH` points to as an image preview -# 7 | image | Display the file directly as an image - -# Script arguments +## If the option `use_preview_script` is set to `true`, +## then this script will be called and its output will be displayed in ranger. +## ANSI color codes are supported. +## STDIN is disabled, so interactive scripts won't work properly + +## This script is considered a configuration file and must be updated manually. +## It will be left untouched if you upgrade ranger. + +## Meanings of exit codes: +## code | meaning | action of ranger +## -----+------------+------------------------------------------- +## 0 | success | Display stdout as preview +## 1 | no preview | Display no preview at all +## 2 | plain text | Display the plain content of the file +## 3 | fix width | Don't reload when width changes +## 4 | fix height | Don't reload when height changes +## 5 | fix both | Don't ever reload +## 6 | image | Display the image `$IMAGE_CACHE_PATH` points to as an image preview +## 7 | image | Display the file directly as an image + +## Script arguments FILE_PATH="${1}" # Full path of the highlighted file PV_WIDTH="${2}" # Width of the preview pane (number of fitting characters) PV_HEIGHT="${3}" # Height of the preview pane (number of fitting characters) @@ -33,7 +33,7 @@ PV_IMAGE_ENABLED="${5}" # 'True' if image previews are enabled, 'False' otherwi FILE_EXTENSION="${FILE_PATH##*.}" FILE_EXTENSION_LOWER="$(printf "%s" "${FILE_EXTENSION}" | tr '[:upper:]' '[:lower:]')" -# Settings +## Settings HIGHLIGHT_SIZE_MAX=262143 # 256KiB HIGHLIGHT_TABWIDTH=${HIGHLIGHT_TABWIDTH:-8} HIGHLIGHT_STYLE=${HIGHLIGHT_STYLE:-pablo} @@ -43,48 +43,48 @@ PYGMENTIZE_STYLE=${PYGMENTIZE_STYLE:-autumn} handle_extension() { case "${FILE_EXTENSION_LOWER}" in - # Archive + ## Archive a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|\ rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z|zip) atool --list -- "${FILE_PATH}" && exit 5 bsdtar --list --file "${FILE_PATH}" && exit 5 exit 1;; rar) - # Avoid password prompt by providing empty password + ## Avoid password prompt by providing empty password unrar lt -p- -- "${FILE_PATH}" && exit 5 exit 1;; 7z) - # Avoid password prompt by providing empty password + ## Avoid password prompt by providing empty password 7z l -p -- "${FILE_PATH}" && exit 5 exit 1;; - # PDF + ## PDF pdf) - # Preview as text conversion + ## Preview as text conversion pdftotext -l 10 -nopgbrk -q -- "${FILE_PATH}" - | fmt -w "${PV_WIDTH}" && exit 5 mutool draw -F txt -i -- "${FILE_PATH}" 1-10 | fmt -w "${PV_WIDTH}" && exit 5 exiftool "${FILE_PATH}" && exit 5 exit 1;; - # BitTorrent + ## BitTorrent torrent) transmission-show -- "${FILE_PATH}" && exit 5 exit 1;; - # OpenDocument + ## OpenDocument odt|ods|odp|sxw) - # Preview as text conversion + ## Preview as text conversion odt2txt "${FILE_PATH}" && exit 5 exit 1;; - # HTML + ## HTML htm|html|xhtml) - # Preview as text conversion + ## Preview as text conversion w3m -dump "${FILE_PATH}" && exit 5 lynx -dump -- "${FILE_PATH}" && exit 5 elinks -dump "${FILE_PATH}" && exit 5 ;; # Continue with next handler on failure - # JSON + ## JSON json) jq --color-output . "${FILE_PATH}" && exit 5 python -m json.tool -- "${FILE_PATH}" && exit 5 @@ -93,46 +93,47 @@ handle_extension() { } handle_image() { - # Size of the preview if there are multiple options or it has to be rendered - # from vector graphics. If the conversion program allows specifying only one - # dimension while keeping the aspect ratio, the width will be used. + ## Size of the preview if there are multiple options or it has to be + ## rendered from vector graphics. If the conversion program allows + ## specifying only one dimension while keeping the aspect ratio, the width + ## will be used. local DEFAULT_SIZE="1920x1080" local mimetype="${1}" case "${mimetype}" in - # SVG + ## SVG # image/svg+xml|image/svg) # convert -- "${FILE_PATH}" "${IMAGE_CACHE_PATH}" && exit 6 # exit 1;; - # DjVu + ## DjVu # image/vnd.djvu) # ddjvu -format=tiff -quality=90 -page=1 -size="${DEFAULT_SIZE}" \ # - "${IMAGE_CACHE_PATH}" < "${FILE_PATH}" \ # && exit 6 || exit 1;; - # Image + ## Image image/*) local orientation orientation="$( identify -format '%[EXIF:Orientation]\n' -- "${FILE_PATH}" )" - # If orientation data is present and the image actually - # needs rotating ("1" means no rotation)... + ## If orientation data is present and the image actually + ## needs rotating ("1" means no rotation)... if [[ -n "$orientation" && "$orientation" != 1 ]]; then - # ...auto-rotate the image according to the EXIF data. + ## ...auto-rotate the image according to the EXIF data. convert -- "${FILE_PATH}" -auto-orient "${IMAGE_CACHE_PATH}" && exit 6 fi - # `w3mimgdisplay` will be called for all images (unless overridden as above), - # but might fail for unsupported types. + ## `w3mimgdisplay` will be called for all images (unless overriden + ## as above), but might fail for unsupported types. exit 7;; - # Video + ## Video # video/*) # # Thumbnail # ffmpegthumbnailer -i "${FILE_PATH}" -o "${IMAGE_CACHE_PATH}" -s 0 && exit 6 # exit 1;; - # PDF + ## PDF # application/pdf) # pdftoppm -f 1 -l 1 \ # -scale-to-x "${DEFAULT_SIZE%x*}" \ @@ -142,18 +143,18 @@ handle_image() { # -- "${FILE_PATH}" "${IMAGE_CACHE_PATH%.*}" \ # && exit 6 || exit 1;; - # ePub, MOBI, FB2 (using Calibre) + ## ePub, MOBI, FB2 (using Calibre) # application/epub+zip|application/x-mobipocket-ebook|application/x-fictionbook+xml) # ebook-meta --get-cover="${IMAGE_CACHE_PATH}" -- "${FILE_PATH}" > /dev/null \ # && exit 6 || exit 1;; - # ePub (using ) + ## ePub (using ) # application/epub+zip) # epub-thumbnailer \ # "${FILE_PATH}" "${IMAGE_CACHE_PATH}" "${DEFAULT_SIZE%x*}" \ # && exit 6 || exit 1;; - # Font + ## Font application/font*|application/*opentype) preview_png="/tmp/$(basename "${IMAGE_CACHE_PATH%.*}").png" if fontimage -o "${preview_png}" \ @@ -174,8 +175,8 @@ handle_image() { fi ;; - # Preview archives using the first image inside. - # (Very useful for comic book collections for example.) + ## Preview archives using the first image inside. + ## (Very useful for comic book collections for example.) # application/zip|application/x-rar|application/x-7z-compressed|\ # application/x-xz|application/x-bzip2|application/x-gzip|application/x-tar) # local fn=""; local fe="" @@ -216,9 +217,9 @@ handle_image() { handle_mime() { local mimetype="${1}" case "${mimetype}" in - # Text + ## Text text/* | */xml) - # Syntax highlight + ## Syntax highlight if [[ "$( stat --printf='%s' -- "${FILE_PATH}" )" -gt "${HIGHLIGHT_SIZE_MAX}" ]]; then exit 2 fi @@ -236,21 +237,21 @@ handle_mime() { -- "${FILE_PATH}" && exit 5 exit 2;; - # DjVu + ## DjVu image/vnd.djvu) - # Preview as text conversion (requires djvulibre) + ## Preview as text conversion (requires djvulibre) djvutxt "${FILE_PATH}" | fmt -w ${PV_WIDTH} && exit 5 exiftool "${FILE_PATH}" && exit 5 exit 1;; - # Image + ## Image image/*) - # Preview as text conversion + ## Preview as text conversion # img2txt --gamma=0.6 --width="${PV_WIDTH}" -- "${FILE_PATH}" && exit 4 exiftool "${FILE_PATH}" && exit 5 exit 1;; - # Video and audio + ## Video and audio video/* | audio/*) mediainfo "${FILE_PATH}" && exit 5 exiftool "${FILE_PATH}" && exit 5 -- cgit 1.4.1-2-gfad0 From f4d280c6fba8487ddfebb5883a4e126300d1746c Mon Sep 17 00:00:00 2001 From: toonn Date: Tue, 9 Oct 2018 15:49:02 +0200 Subject: Add a section for commands to avoid SC2034 warnings Shellcheck warns about unused variables, for good reason, but sometimes you legitimately want to include an unused variable in a script. Rather than ignore the warning completely I decided to circumvent the warning through the use of fluff (useless commands that "use" variables). --- ranger/data/scope.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh index 9dad8609..6ff5e3c3 100755 --- a/ranger/data/scope.sh +++ b/ranger/data/scope.sh @@ -274,3 +274,6 @@ handle_mime "${MIMETYPE}" handle_fallback exit 1 + +## Section for silly commands to avoid "appears unused" warnings +#echo "${PV_HEIGHT}" -- cgit 1.4.1-2-gfad0 From e91ae58705d244f347c09c1c538245c02b0ea1ba Mon Sep 17 00:00:00 2001 From: toonn Date: Tue, 9 Oct 2018 16:10:51 +0200 Subject: Add shellcheck to tests Shellcheck is run for `scope.sh` after uncommenting all the code. --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c6b3b35d..c4bd5bb2 100644 --- a/Makefile +++ b/Makefile @@ -108,11 +108,15 @@ test_pytest: @echo "Running py.test tests..." py.test tests +test_shellcheck: + @echo "Running shellcheck..." + sed '2,$$s/^\( *\)#/\1/' ./ranger/data/scope.sh | shellcheck -a - + test_other: @echo "Checking completeness of man page..." @tests/manpage_completion_test.py -test: test_pylint test_flake8 test_doctest test_pytest test_other +test: test_pylint test_flake8 test_doctest test_pytest test_shellcheck test_other @echo "Finished testing: All tests passed!" man: -- cgit 1.4.1-2-gfad0 From a007755400344fe1418d74add9787d2ab0482ca7 Mon Sep 17 00:00:00 2001 From: toonn Date: Tue, 9 Oct 2018 18:12:14 +0200 Subject: Document shellcheck in Makefile help and HACKING.md --- HACKING.md | 4 ++-- Makefile | 31 ++++++++++++++++--------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/HACKING.md b/HACKING.md index 6e200a43..aeb4f072 100644 --- a/HACKING.md +++ b/HACKING.md @@ -7,8 +7,8 @@ Coding Style * Use syntax compatible with Python `2.6+` and `3.1+`. * Use docstrings with `pydoc` in mind * Follow the PEP8 style guide: https://www.python.org/dev/peps/pep-0008/ -* Always run `make test` before submitting a new PR. `pylint`, `flake8` and - `pytest` needs to be installed. +* Always run `make test` before submitting a new PR. `pylint`, `flake8`, + `pytest`, `doctest` and `shellcheck` need to be installed. * When breaking backward compatibility with old configuration files or plugins, please include a temporary workaround code that provides a compatibility layer and mark it with a comment that includes the word `COMPAT`. For diff --git a/Makefile b/Makefile index c4bd5bb2..3f6e459d 100644 --- a/Makefile +++ b/Makefile @@ -38,21 +38,22 @@ options: help @echo 'DESTDIR = $(DESTDIR)' help: - @echo 'make: Test and compile ranger.' - @echo 'make install: Install $(NAME)' - @echo 'make pypi_sdist: Release a new sdist to PyPI' - @echo 'make clean: Remove the compiled files (*.pyc, *.pyo)' - @echo 'make doc: Create the pydoc documentation' - @echo 'make cleandoc: Remove the pydoc documentation' - @echo 'make man: Compile the manpage with "pod2man"' - @echo 'make manhtml: Compile the html manpage with "pod2html"' - @echo 'make snapshot: Create a tar.gz of the current git revision' - @echo 'make test: Test everything' - @echo 'make test_pylint: Test using pylint' - @echo 'make test_flake8: Test using flake8' - @echo 'make test_doctest: Test using doctest' - @echo 'make test_pytest: Test using pytest' - @echo 'make todo: Look for TODO and XXX markers in the source code' + @echo 'make: Test and compile ranger.' + @echo 'make install: Install $(NAME)' + @echo 'make pypi_sdist: Release a new sdist to PyPI' + @echo 'make clean: Remove the compiled files (*.pyc, *.pyo)' + @echo 'make doc: Create the pydoc documentation' + @echo 'make cleandoc: Remove the pydoc documentation' + @echo 'make man: Compile the manpage with "pod2man"' + @echo 'make manhtml: Compile the html manpage with "pod2html"' + @echo 'make snapshot: Create a tar.gz of the current git revision' + @echo 'make test: Test everything' + @echo 'make test_pylint: Test using pylint' + @echo 'make test_flake8: Test using flake8' + @echo 'make test_doctest: Test using doctest' + @echo 'make test_pytest: Test using pytest' + @echo 'make test_shellcheck: Test using shellcheck' + @echo 'make todo: Look for TODO and XXX markers in the source code' install: $(PYTHON) setup.py install $(SETUPOPTS) \ -- cgit 1.4.1-2-gfad0 From 85e1c59ab9f918a2437fda8161b68cc1934ef33e Mon Sep 17 00:00:00 2001 From: toonn Date: Tue, 9 Oct 2018 19:12:52 +0200 Subject: Mention the test_py target in HACKING.md --- HACKING.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/HACKING.md b/HACKING.md index aeb4f072..c3faf3ca 100644 --- a/HACKING.md +++ b/HACKING.md @@ -8,7 +8,9 @@ Coding Style * Use docstrings with `pydoc` in mind * Follow the PEP8 style guide: https://www.python.org/dev/peps/pep-0008/ * Always run `make test` before submitting a new PR. `pylint`, `flake8`, - `pytest`, `doctest` and `shellcheck` need to be installed. + `pytest`, `doctest` and `shellcheck` need to be installed. (If you don't + change any shell scripts you can run `make test_py` and you don't need the + `shellcheck` dependency but it's an awesome tool, so check it out : ) * When breaking backward compatibility with old configuration files or plugins, please include a temporary workaround code that provides a compatibility layer and mark it with a comment that includes the word `COMPAT`. For -- cgit 1.4.1-2-gfad0 From 88b4d3747072db6e39fb44fff6055ba842b3203f Mon Sep 17 00:00:00 2001 From: toonn Date: Sun, 14 Oct 2018 20:37:33 +0200 Subject: Add test_py target --- Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Makefile b/Makefile index 3f6e459d..0c2dbe46 100644 --- a/Makefile +++ b/Makefile @@ -52,6 +52,8 @@ help: @echo 'make test_flake8: Test using flake8' @echo 'make test_doctest: Test using doctest' @echo 'make test_pytest: Test using pytest' + @echo 'make test_other: Verify the manpage is complete' + @echo 'make test_py: Run all python tests, including manpage completeness' @echo 'make test_shellcheck: Test using shellcheck' @echo 'make todo: Look for TODO and XXX markers in the source code' @@ -109,6 +111,9 @@ test_pytest: @echo "Running py.test tests..." py.test tests +test_py: test_pylint test_flake8 test_doctest test_pytest test_other + @echo "Finished python and documentation tests..." + test_shellcheck: @echo "Running shellcheck..." sed '2,$$s/^\( *\)#/\1/' ./ranger/data/scope.sh | shellcheck -a - -- cgit 1.4.1-2-gfad0 From 2c0f1112150af11c1ece2ac889ddf12d643fff04 Mon Sep 17 00:00:00 2001 From: toonn Date: Sun, 14 Oct 2018 20:52:11 +0200 Subject: Document ## convention and $$ sed range --- Makefile | 1 + ranger/data/scope.sh | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/Makefile b/Makefile index 0c2dbe46..4daf0b46 100644 --- a/Makefile +++ b/Makefile @@ -116,6 +116,7 @@ test_py: test_pylint test_flake8 test_doctest test_pytest test_other test_shellcheck: @echo "Running shellcheck..." + # The $ for the range needs to be escaped because of make. sed '2,$$s/^\( *\)#/\1/' ./ranger/data/scope.sh | shellcheck -a - test_other: diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh index 6ff5e3c3..6217af70 100755 --- a/ranger/data/scope.sh +++ b/ranger/data/scope.sh @@ -11,6 +11,10 @@ IFS=$'\n' ## This script is considered a configuration file and must be updated manually. ## It will be left untouched if you upgrade ranger. +## Because of some automated testing we do on the script #'s for comments need +## to be doubled up. Code that is commented out, because it's an alternative for +## example, gets only one #. + ## Meanings of exit codes: ## code | meaning | action of ranger ## -----+------------+------------------------------------------- -- cgit 1.4.1-2-gfad0 From e416bfe7f545745f136c7a01b00c6471627b2bfa Mon Sep 17 00:00:00 2001 From: toonn Date: Sun, 14 Oct 2018 23:20:56 +0200 Subject: Replace targets with test_py It's easier to keep the test and test_py targets synchronized by having the former depend on the latter. Changed the wording of the test_py success message to be less suspenseful. --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 4daf0b46..ede6120f 100644 --- a/Makefile +++ b/Makefile @@ -112,7 +112,7 @@ test_pytest: py.test tests test_py: test_pylint test_flake8 test_doctest test_pytest test_other - @echo "Finished python and documentation tests..." + @echo "Finished python and documentation tests!" test_shellcheck: @echo "Running shellcheck..." @@ -123,7 +123,7 @@ test_other: @echo "Checking completeness of man page..." @tests/manpage_completion_test.py -test: test_pylint test_flake8 test_doctest test_pytest test_shellcheck test_other +test: test_py test_shellcheck @echo "Finished testing: All tests passed!" man: -- cgit 1.4.1-2-gfad0 From 2f7b54d06ae351171a2f60c916015a1e9f417911 Mon Sep 17 00:00:00 2001 From: toonn Date: Thu, 6 Jun 2019 22:03:00 +0200 Subject: Remove comment in shellcheck rule The comment was confusing because `make` swallowed the `$` --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index ede6120f..27280abd 100644 --- a/Makefile +++ b/Makefile @@ -116,7 +116,6 @@ test_py: test_pylint test_flake8 test_doctest test_pytest test_other test_shellcheck: @echo "Running shellcheck..." - # The $ for the range needs to be escaped because of make. sed '2,$$s/^\( *\)#/\1/' ./ranger/data/scope.sh | shellcheck -a - test_other: -- cgit 1.4.1-2-gfad0 From d2be920ecf16a537026ce4fd79e4d4994964b6c3 Mon Sep 17 00:00:00 2001 From: toonn Date: Fri, 7 Jun 2019 19:54:51 +0200 Subject: Replace fluff command with shellcheck directive Hid an `echo $VAR` in a comment to get rid of the unused variable warning, that's now been replaced with a shellcheck directives suited to the purpose. --- ranger/data/scope.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh index 6217af70..e211b50b 100755 --- a/ranger/data/scope.sh +++ b/ranger/data/scope.sh @@ -30,6 +30,7 @@ IFS=$'\n' ## Script arguments FILE_PATH="${1}" # Full path of the highlighted file PV_WIDTH="${2}" # Width of the preview pane (number of fitting characters) +## shellcheck disable=SC2034 # PV_HEIGHT is provided for convenience and unused PV_HEIGHT="${3}" # Height of the preview pane (number of fitting characters) IMAGE_CACHE_PATH="${4}" # Full path that should be used to cache image preview PV_IMAGE_ENABLED="${5}" # 'True' if image previews are enabled, 'False' otherwise. @@ -278,6 +279,3 @@ handle_mime "${MIMETYPE}" handle_fallback exit 1 - -## Section for silly commands to avoid "appears unused" warnings -#echo "${PV_HEIGHT}" -- cgit 1.4.1-2-gfad0 From 5f29f89a03aa3d3f9e47e87f68d66e416f084556 Mon Sep 17 00:00:00 2001 From: toonn Date: Tue, 18 Jun 2019 13:05:51 +0200 Subject: Tabs are spaces too --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 27280abd..87c5ff1b 100644 --- a/Makefile +++ b/Makefile @@ -116,7 +116,7 @@ test_py: test_pylint test_flake8 test_doctest test_pytest test_other test_shellcheck: @echo "Running shellcheck..." - sed '2,$$s/^\( *\)#/\1/' ./ranger/data/scope.sh | shellcheck -a - + sed '2,$$s/^\(\s*\)#/\1/' ./ranger/data/scope.sh | shellcheck -a - test_other: @echo "Checking completeness of man page..." -- cgit 1.4.1-2-gfad0 From 85445558bd57ffcadc05ca5b89ec76ec69a384bc Mon Sep 17 00:00:00 2001 From: toonn Date: Tue, 18 Jun 2019 14:30:53 +0200 Subject: Fix shellcheck warnings for new additions Rewrote the epub clauses to avoid overlap warnings `SC2221/SC2222`, users could've potentially been confused if they uncommented both Calibre and epub-thumbnailer clauses and didn't see epub-thumbnailer previews. --- ranger/data/scope.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh index e211b50b..306eeed0 100755 --- a/ranger/data/scope.sh +++ b/ranger/data/scope.sh @@ -148,16 +148,16 @@ handle_image() { # -- "${FILE_PATH}" "${IMAGE_CACHE_PATH%.*}" \ # && exit 6 || exit 1;; - ## ePub, MOBI, FB2 (using Calibre) - # application/epub+zip|application/x-mobipocket-ebook|application/x-fictionbook+xml) - # ebook-meta --get-cover="${IMAGE_CACHE_PATH}" -- "${FILE_PATH}" > /dev/null \ - # && exit 6 || exit 1;; - ## ePub (using ) - # application/epub+zip) - # epub-thumbnailer \ - # "${FILE_PATH}" "${IMAGE_CACHE_PATH}" "${DEFAULT_SIZE%x*}" \ - # && exit 6 || exit 1;; + ## ePub, MOBI, FB2 (using Calibre) + # application/epub+zip|application/x-mobipocket-ebook|\ + # application/x-fictionbook+xml) + # # ePub (using https://github.com/marianosimone/epub-thumbnailer) + # epub-thumbnailer "${FILE_PATH}" "${IMAGE_CACHE_PATH}" \ + # "${DEFAULT_SIZE%x*}" && exit 6 + # ebook-meta --get-cover="${IMAGE_CACHE_PATH}" -- "${FILE_PATH}" \ + # >/dev/null && exit 6 + # exit 1;; ## Font application/font*|application/*opentype) @@ -245,7 +245,7 @@ handle_mime() { ## DjVu image/vnd.djvu) ## Preview as text conversion (requires djvulibre) - djvutxt "${FILE_PATH}" | fmt -w ${PV_WIDTH} && exit 5 + djvutxt "${FILE_PATH}" | fmt -w "${PV_WIDTH}" && exit 5 exiftool "${FILE_PATH}" && exit 5 exit 1;; -- cgit 1.4.1-2-gfad0