We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The attached patch …
SPDX-FileCopyrightText
sed
${variable//search/replace}
📎 shellcheck.diff.txt
It passes shellcheck and seems to work just fine here, but somebody should probably check it on their side.
Overview:
diff --git a/man.filter.dpi b/man.filter.dpi index 5b9adbc..bc0fb3d 100755 --- a/man.filter.dpi +++ b/man.filter.dpi @@ -1,13 +1,14 @@ #!/bin/bash -# Copyright (c) 2023 Rodrigo Arias Mallo +# SPDX-FileCopyrightText: Copyright (c) 2023 Rodrigo Arias Mallo # SPDX-License-Identifier: GPL-3.0-or-later -IFS= read -d '>' auth # Ignore auth -IFS= read -d '>' cmd +# shellcheck disable=SC2034 +IFS= read -rd '>' auth # Ignore auth +IFS= read -rd '>' cmd case "$cmd" in "<cmd='open_url' url='"*);; - *) echo $cmd; exit;; + *) echo "$cmd"; exit;; esac url=${cmd#"<cmd='open_url' url='"} @@ -17,20 +18,20 @@ serve_404() { printf "<cmd='start_send_page' url='' '>\n" printf "Content-type: text/plain\r\n\r\n" manpage="$1" - apropos="$2" - if [ -z "$1" ]; then + test -n "$manpage" || { echo "Not found" exit 0 - fi - echo "Manual page not found: $1" - if [ -n "$apropos" ]; then + } + apropos="$2" + echo "Manual page not found: $manpage" + test -n "$apropos" && { printf "\nRelated pages:\n" man -k "$apropos" - fi + } } inject_css() { - css=$(cat "$(dirname $(readlink -f $0))/style.css" | tr '\n' ' ') + css=$(tr '\n' ' ' < "$(dirname "$(readlink -f "$0")")/style.css") sed "s_</style>_$css\n</style>_" } @@ -54,19 +55,23 @@ serve_manpage() { url="$1" ref="${url#"man:"}" # Reverse open(3) -> 3 open if given - manpage=$(echo "$ref" | sed 's/\(.*\)(\(.*\))/\2 \1/') + # shellcheck disable=SC2001 + manpage=$(sed 's/\(.*\)(\(.*\))/\2 \1/' <<< "$ref") # If page not found, return 404 - if [ -z "$manpage" ]; then + test -z "$manpage" && { serve_404 exit 0 - fi + } + # $manpage may contain both man section and man page + # shellcheck disable=SC2086 if ! man -w $manpage 2>/dev/null; then - apropos=$(echo "$ref" | sed 's/(.*)//') + apropos="${ref%%(*}" serve_404 "$manpage" "$apropos" else printf "<cmd='start_send_page' url='' '>\n" printf "Content-type: text/html\r\n\r\n" unset MANROFFOPT + # shellcheck disable=SC2086 man -Thtml $manpage | fix_br | inject_css | link_xrefs 2>&1 fi }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The attached patch …
SPDX-FileCopyrightText
,sed
in favour of${variable//search/replace}
, and📎 shellcheck.diff.txt
It passes shellcheck and seems to work just fine here, but somebody should probably check it on their side.
Overview:
The text was updated successfully, but these errors were encountered: