Skip to content

Commit

Permalink
posix: use tail -1, not tail -n 1, prefer gsed for Solaris compat
Browse files Browse the repository at this point in the history
Signed-off-by: Yury V. Zaytsev <[email protected]>
  • Loading branch information
zyv committed Oct 20, 2024
1 parent 2a9845e commit c021100
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/vfs/extfs/helpers/changesetfs
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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" ;;
Expand Down
4 changes: 2 additions & 2 deletions src/vfs/extfs/helpers/iso9660.in
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions src/vfs/extfs/helpers/patchsetfs
Original file line number Diff line number Diff line change
Expand Up @@ -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" ;;
Expand Down
4 changes: 3 additions & 1 deletion src/vfs/extfs/helpers/rpm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/vfs/shell/shelldef.h
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down

0 comments on commit c021100

Please sign in to comment.