Skip to content

Commit

Permalink
general: Remove redundant usage of cat
Browse files Browse the repository at this point in the history
In general, the substitution ‘$(cat foo)’ may be replaced by the
equivalent but faster ‘$(<foo)’.
  • Loading branch information
indrajitr committed Apr 30, 2021
1 parent a2f3f41 commit a71b2d0
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion modules/archive/functions/archive
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
local archive_name path_to_archive _gzip_bin _bzip2_bin _xz_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:
Expand Down
2 changes: 1 addition & 1 deletion modules/archive/functions/lsarchive
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
local verbose

if (( $# == 0 )); then
cat >&2 <<EOF
>&2 <<EOF
usage: $0 [-option] [file ...]

options:
Expand Down
2 changes: 1 addition & 1 deletion modules/archive/functions/unarchive
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ local extract_dir
local _gzip_bin _bzip2_bin _xz_bin

if (( $# == 0 )); then
cat >&2 <<EOF
>&2 <<EOF
usage: $0 [-option] [file ...]

options:
Expand Down
2 changes: 1 addition & 1 deletion modules/dpkg/functions/deb-history
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/python/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function _python-workon-cwd {
# Check for virtualenv name override
local ENV_NAME=""
if [[ -f "$PROJECT_ROOT/.venv" ]]; then
ENV_NAME="$(cat "$PROJECT_ROOT/.venv")"
ENV_NAME="$(<"$PROJECT_ROOT/.venv")"
elif [[ -f "$PROJECT_ROOT/.venv/bin/activate" ]]; then
ENV_NAME="$PROJECT_ROOT/.venv"
elif [[ "$PROJECT_ROOT" != "." ]]; then
Expand Down
3 changes: 1 addition & 2 deletions modules/utility/functions/prep
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

local usage pattern modifiers invert

usage="$(
cat <<EOF
usage="$(<<EOF
usage: $0 [-option ...] [--] pattern [file ...]

options:
Expand Down
3 changes: 1 addition & 2 deletions modules/utility/functions/psub
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

local usage pattern replacement modifiers

usage="$(
cat <<EOF
usage="$(<<EOF
usage: $0 [-option ...] [--] pattern replacement [file ...]

options:
Expand Down
3 changes: 1 addition & 2 deletions modules/utility/functions/zsh-help
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit a71b2d0

Please sign in to comment.