From d290cc6456507de0d03d469518e85b5e59afd6fa Mon Sep 17 00:00:00 2001 From: "Yury V. Zaytsev" Date: Sun, 20 Oct 2024 13:49:24 +0200 Subject: [PATCH] posix: use `tail -1`, not `tail -n 1`, prefer `gsed` for Solaris compat Signed-off-by: Yury V. Zaytsev --- src/vfs/extfs/helpers/changesetfs | 6 +++--- src/vfs/extfs/helpers/iso9660.in | 4 ++-- src/vfs/extfs/helpers/patchsetfs | 4 ++-- src/vfs/extfs/helpers/rpm | 4 +++- src/vfs/shell/shelldef.h | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/vfs/extfs/helpers/changesetfs b/src/vfs/extfs/helpers/changesetfs index eebdf8c7c3..4c8eb7acbf 100755 --- a/src/vfs/extfs/helpers/changesetfs +++ b/src/vfs/extfs/helpers/changesetfs @@ -57,7 +57,7 @@ changesetfs_copyout_git() [ -z "$GIT_DIR" ] && GIT_DIR=$WORK_DIR filecommit=`git --git-dir="$GIT_DIR" show --raw --pretty=tformat:%h "$chset" -- "$fname"| \ - tail -n1 | \ + tail -1 | \ sed 's@^::[0-9]*\s*[0-9]*\s*[0-9]*\s*@@' | \ sed 's@^:[0-9]*\s*[0-9]*\s*@@' | \ cut -d'.' -f 1` @@ -98,8 +98,8 @@ command=$1; shift tmp_file=$1; shift WORK_DIR=`head -n1 $tmp_file` -fname=`tail -n2 $tmp_file | head -n1` -VCS_type=`tail -n1 $tmp_file` +fname=`tail -2 $tmp_file | head -n1` +VCS_type=`tail -1 $tmp_file` case "$command" in list) changesetfs_list "$VCS_type" "$WORK_DIR" "$fname" ;; diff --git a/src/vfs/extfs/helpers/iso9660.in b/src/vfs/extfs/helpers/iso9660.in index 078faa6746..e5d41dafe1 100644 --- a/src/vfs/extfs/helpers/iso9660.in +++ b/src/vfs/extfs/helpers/iso9660.in @@ -97,10 +97,10 @@ xorriso_list() ( fi # The first line is /, skip it - tail -n+2 "$temp_ls" | + sed 1,1d "$temp_ls" | # disk_ops.c:Xorriso_format_ls_l() prints the boot catalog file as of # type "e". Make it a generic file - sed -E 's,^e,-,' | + sed 's,^e,-,' | @AWK@ "$awk_xorriso_unesc" rm -f "$temp_ls" diff --git a/src/vfs/extfs/helpers/patchsetfs b/src/vfs/extfs/helpers/patchsetfs index 9bbe9f97d3..3096a49bb2 100755 --- a/src/vfs/extfs/helpers/patchsetfs +++ b/src/vfs/extfs/helpers/patchsetfs @@ -93,8 +93,8 @@ command=$1; shift tmp_file=$1; shift WORK_DIR=`head -n1 $tmp_file` -fname=`tail -n2 $tmp_file | head -n1` -VCS_type=`tail -n1 $tmp_file` +fname=`tail -2 $tmp_file | head -n1` +VCS_type=`tail -1 $tmp_file` case "$command" in list) patchsetfs_list "$VCS_type" "$WORK_DIR" "$fname" ;; diff --git a/src/vfs/extfs/helpers/rpm b/src/vfs/extfs/helpers/rpm index 47b2e6e730..20520bf416 100755 --- a/src/vfs/extfs/helpers/rpm +++ b/src/vfs/extfs/helpers/rpm @@ -69,7 +69,9 @@ fi RPM_QUERY_FMT="$RPM -qp --qf" RPM2CPIO="rpm2cpio" -SED="sed" +# Prefer `gsed` on Solaris due to complex regex +SED=`command -v gsed 2>/dev/null` \ + || SED=`command -v sed 2>/dev/null` param=$1; shift rpm_filename=$1; shift diff --git a/src/vfs/shell/shelldef.h b/src/vfs/shell/shelldef.h index 37244d9804..fd56462dad 100644 --- a/src/vfs/shell/shelldef.h +++ b/src/vfs/shell/shelldef.h @@ -192,7 +192,7 @@ "if `ls -Q / >/dev/null 2>&1` ; then\n" \ " res=`expr $res + 16`\n" \ "fi\n" \ -"dat=`ls -lan / 2>/dev/null | head -n 3 | tail -n 1 | (\n" \ +"dat=`ls -lan / 2>/dev/null | head -n 3 | tail -1 | (\n" \ " while read p l u g s rec; do\n" \ " if [ -n \"$g\" ]; then\n" \ " if [ -n \"$l\" ]; then\n" \