From 84e0787411aaa2caaff89ff167a3536bda410a58 Mon Sep 17 00:00:00 2001 From: Indrajit Raychaudhuri <irc@indrajit.com> Date: Thu, 29 Apr 2021 21:49:37 -0500 Subject: [PATCH] general: Remove redundant usage of `cat` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In general, the substitution ‘$(cat foo)’ may be replaced by the equivalent but faster ‘$(<foo)’. See: https://zsh.sourceforge.io/Doc/Release/Expansion.html#Command-Substitution --- modules/archive/functions/archive | 2 +- modules/archive/functions/lsarchive | 2 +- modules/archive/functions/unarchive | 2 +- modules/dpkg/functions/deb-history | 2 +- modules/utility/functions/prep | 3 +-- modules/utility/functions/psub | 3 +-- modules/utility/functions/zsh-help | 3 +-- 7 files changed, 7 insertions(+), 10 deletions(-) diff --git a/modules/archive/functions/archive b/modules/archive/functions/archive index b6f95231..6f26cf5b 100644 --- a/modules/archive/functions/archive +++ b/modules/archive/functions/archive @@ -10,7 +10,7 @@ local archive_name path_to_archive _gzip_bin _bzip2_bin _xz_bin _zstd_bin if (( $# < 2 )); then - cat >&2 <<EOF + >&2 <<EOF usage: $0 [archive_name.zip] [/path/to/include/into/archive ...] Where 'archive.zip' uses any of the following extensions: diff --git a/modules/archive/functions/lsarchive b/modules/archive/functions/lsarchive index 2506b87f..6518394f 100644 --- a/modules/archive/functions/lsarchive +++ b/modules/archive/functions/lsarchive @@ -10,7 +10,7 @@ local verbose if (( $# == 0 )); then - cat >&2 <<EOF + >&2 <<EOF usage: $0 [-option] [file ...] options: diff --git a/modules/archive/functions/unarchive b/modules/archive/functions/unarchive index 3e58b867..0b442564 100644 --- a/modules/archive/functions/unarchive +++ b/modules/archive/functions/unarchive @@ -15,7 +15,7 @@ local extract_dir local _gzip_bin _bzip2_bin _xz_bin _zstd_bin if (( $# == 0 )); then - cat >&2 <<EOF + >&2 <<EOF usage: $0 [-option] [file ...] options: diff --git a/modules/dpkg/functions/deb-history b/modules/dpkg/functions/deb-history index a1369dea..bc83d59c 100644 --- a/modules/dpkg/functions/deb-history +++ b/modules/dpkg/functions/deb-history @@ -26,7 +26,7 @@ case "$1" in zcat $(ls -rt /var/log/dpkg*) ;; (*) - cat >&2 <<EOF + >&2 <<EOF Commands: install - List installed packages upgrade - List upgraded packages diff --git a/modules/utility/functions/prep b/modules/utility/functions/prep index d6448aeb..32227b27 100644 --- a/modules/utility/functions/prep +++ b/modules/utility/functions/prep @@ -9,8 +9,7 @@ local usage pattern modifiers invert -usage="$( -cat <<EOF +usage="$(<<EOF usage: $0 [-option ...] [--] pattern [file ...] options: diff --git a/modules/utility/functions/psub b/modules/utility/functions/psub index af191fde..d63b8e1d 100644 --- a/modules/utility/functions/psub +++ b/modules/utility/functions/psub @@ -9,8 +9,7 @@ local usage pattern replacement modifiers -usage="$( -cat <<EOF +usage="$(<<EOF usage: $0 [-option ...] [--] pattern replacement [file ...] options: diff --git a/modules/utility/functions/zsh-help b/modules/utility/functions/zsh-help index f6605ea0..95b91989 100644 --- a/modules/utility/functions/zsh-help +++ b/modules/utility/functions/zsh-help @@ -9,8 +9,7 @@ # function zsh-help { -local usage="$( -cat <<EOF +local usage="$(<<EOF usage: $0 [--help] [--zsh-help-debug] [--all] search term(s) Options: --all - search for the term anywhere, not just at the start of a line.