(#9400 P3a) Replace useless cat with input redirection (#9404)

* (#9400 P3a) trap-logging: replace useless cat with direct file arguments

- gzip < file → gzip -c file (direct argument, -c for stdout)
- cat file | ansi2txt → ansi2txt < file (ansi2txt has no file argument)
- Remove now-unnecessary shellcheck disable=SC2002 comments

* (#9400 P3a) logging: replace useless cat with direct file argument

- cat file | grep | sed → grep file | sed (grep accepts filename directly)
- Remove now-unnecessary shellcheck disable=SC2002 comment

* (#9400 P3a) initrd: replace useless cat with direct file argument

- cat file | md5sum → md5sum file (md5sum accepts filename directly)

* (#9400 P3a) write-device: replace useless cat with direct file argument

- cat file | awk → awk file (awk accepts filename directly)
- Remove now-unnecessary shellcheck disable=SC2002 comment

* (#9400 P3a) export-logs: replace useless cat with direct file argument

- cat file | sed → sed file (sed accepts filename directly)
- Remove now-unnecessary shellcheck disable=SC2002 comment

* (#9400 P3a) python-tools: replace cat subshell with $(<file) syntax

- $(cat file) → $(< file) (bash builtin, no subprocess)

* (#9400 P3a) artifact-armbian-base-files: replace useless cat with direct file argument

- cat file | grep → grep file (grep accepts filename directly)
This commit is contained in:
Igor Velkov 2026-02-18 10:28:14 +02:00 committed by GitHub
parent c184eda283
commit ed371f5f5a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 9 additions and 14 deletions

View File

@ -56,7 +56,7 @@ function artifact_armbian-base-files_prepare_version() {
artifact_name="armbian-base-files-${RELEASE}-${ARCH}"
artifact_type="deb"
artifact_deb_repo="extra/${RELEASE}-utils" # release-specific repo (jammy etc)
artifact_deb_arch="${ARCH}" # arch-specific packages (arm64 etc)
artifact_deb_arch="${ARCH}" # arch-specific packages (arm64 etc)
artifact_map_packages=(["armbian-base-files"]="base-files")
# Important. Force the final reversioned version to contain the release name.
@ -114,7 +114,7 @@ function compile_armbian-base-files() {
Version: ${artifact_version}
EOD
# Keep everything else from original
cat "${destination}/DEBIAN/control" | grep -vP '^(Maintainer|Version):' >> "${destination}/DEBIAN/control.new"
grep -vP '^(Maintainer|Version):' "${destination}/DEBIAN/control" >> "${destination}/DEBIAN/control.new"
# Replace 'Debian' with 'Armbian'.
sed -i "s/Debian/${VENDOR}/g" "${destination}/DEBIAN/control.new"

View File

@ -62,7 +62,7 @@ function prepare_python_and_pip() {
display_alert "pip3 version" "${pip3_version_number}" "info"
# Calculate the hash for the Pip requirements
python3_pip_dependencies_hash="$(echo "${HOSTRELEASE}" "${python3_version}" "${pip3_version_number}" "$(cat "${python3_pip_dependencies_path}")" | sha256sum | cut -d' ' -f1)"
python3_pip_dependencies_hash="$(echo "${HOSTRELEASE}" "${python3_version}" "${pip3_version_number}" "$(< "${python3_pip_dependencies_path}")" | sha256sum | cut -d' ' -f1)"
declare non_cache_dir="/armbian-pip"
declare python_pip_cache="${SRC}/cache/pip"

View File

@ -70,7 +70,7 @@ update_initramfs() {
awk '{print $2 " - " $1}' |
sed -e "s|^${chroot_target}||g" | LC_ALL=C sort > "${initrd_cache_current_manifest_filepath}"
initrd_hash="$(cat "${initrd_cache_current_manifest_filepath}" | md5sum | cut -d ' ' -f 1)" # hash of the hashes.
initrd_hash="$(md5sum "${initrd_cache_current_manifest_filepath}" | cut -d ' ' -f 1)" # hash of the hashes.
initrd_cache_key="initrd.img-${initrd_kern_ver}-${initrd_hash}"
initrd_cache_file_path="${SRC}/cache/initrd/${initrd_cache_key}"
display_alert "initrd cache hash" "${initrd_hash}" "debug"

View File

@ -17,8 +17,7 @@ function write_image_to_device() {
# create sha256sum if it does not exist. we need it for comparison, later.
local if_sha=""
if [[ -f "${image_file}.img.sha" ]]; then
# shellcheck disable=SC2002 # cat most definitely is useful. she purrs.
if_sha=$(cat "${image_file}.sha" | awk '{print $1}')
if_sha=$(awk '{print $1}' "${image_file}.sha")
else
if_sha=$(sha256sum -b "${image_file}" | awk '{print $1}')
fi

View File

@ -155,10 +155,9 @@ function export_ansi_logs() {
# shellcheck disable=SC2001 # I saw, and I can't
logfile_title="$(echo "${logfile_base}" | sed -e 's/^[^.]*\.[^.]*\.//')"
# shellcheck disable=SC2002 # cats, not useless, I like.
cat <<- ANSI_ONE_LOGFILE >> "${target_file}"
$(echo -e -n "${bright_blue_color}")### ${logfile_title} $(echo -e -n "${ansi_reset_color}")
$(cat "${logfile_full}" | sed -e "${prefix_sed_cmd}")
$(sed -e "${prefix_sed_cmd}" "${logfile_full}")
${dim_line_separator}
ANSI_ONE_LOGFILE
done

View File

@ -95,8 +95,7 @@ function logging_error_show_log() {
local prefix_sed_cmd="s/^/${prefix_sed_contents}/;"
CURRENT_LOGFILE="" display_alert " 👇👇👇 Showing logfile below 👇👇👇" "${logfile_to_show}" "err"
# shellcheck disable=SC2002 # my cat is great. thank you, shellcheck.
cat "${logfile_to_show}" | grep -v -e "^$" | sed -e "${prefix_sed_cmd}" 1>&2 # write it to stderr!!
grep -v -e "^$" "${logfile_to_show}" | sed -e "${prefix_sed_cmd}" 1>&2 # write it to stderr!!
CURRENT_LOGFILE="" display_alert " 👆👆👆 Showing logfile above 👆👆👆" "${logfile_to_show}" "err"
else

View File

@ -58,8 +58,7 @@ function trap_handler_cleanup_logging() {
zstdmt --quiet "${one_old_logfile}" -o "${target_archive_path}/${old_logfile_fn}.zst"
reset_uid_owner "${target_archive_path}/${old_logfile_fn}.zst"
else
# shellcheck disable=SC2002 # my cat is not useless. a bit whiny. not useless.
cat "${one_old_logfile}" | gzip > "${target_archive_path}/${old_logfile_fn}.gz"
gzip -c "${one_old_logfile}" > "${target_archive_path}/${old_logfile_fn}.gz"
reset_uid_owner "${target_archive_path}/${old_logfile_fn}.gz"
fi
rm -f "${one_old_logfile}"
@ -97,8 +96,7 @@ function trap_handler_cleanup_logging() {
# ASCII logs, via ansi2txt, if available.
local ascii_log_file="${target_path}/log-${ARMBIAN_LOG_CLI_ID}-${ARMBIAN_BUILD_UUID}.log"
if [[ -n "$(command -v ansi2txt)" ]]; then
# shellcheck disable=SC2002 # gotta pipe, man. I know.
cat "${ansi_log_file}" | ansi2txt >> "${ascii_log_file}"
ansi2txt < "${ansi_log_file}" >> "${ascii_log_file}"
fi
# Export Markdown assets, but not if in GHA and GHA_EXPORT_MD_SUMMARY != yes