Skip to content

fix: add compatibility wrapper for tail#1572

Open
akinomyoga wants to merge 2 commits intoscop:mainfrom
akinomyoga:sed-4
Open

fix: add compatibility wrapper for tail#1572
akinomyoga wants to merge 2 commits intoscop:mainfrom
akinomyoga:sed-4

Conversation

@akinomyoga
Copy link
Collaborator

@akinomyoga akinomyoga commented Feb 12, 2026

This fixes the uses of tail -n +2 in Solaris mentioned in #1567 (comment).

See the commit message of 994dfde for details.


#1567 (comment)

I don't know if it matters at all, just happened to notice now, but in other places we have a space between -n and +2.

Yeah, I noticed the difference in the style. Technically, both -n +2 and -n+2 should be supported based on POSIX, but it would be better to normalize the style in the codebase. I changed it in commit 994dfde.

#1567 (comment)

Given the info on tail -n +2 not working on Solaris, this change and the one below are unfortunate in the sense that they are in a if $OSTYPE block that specifically targets Solaris (and AIX).

#1567 (comment)

This being the other change mentioned above.

I also checked the online manuals of AIX, but AIX tail seems to be fine; it supports the option -n +<num>.

#1567 (comment)
I think we should care about what we are willing to maintain and can test. Or in other words, what we care about :)

As far as I'm personally concerned, that no longer includes any Solaris version as I don't have access to one nor can I test with one these days. I have no problem if others want to support it as long as it doesn't get too badly on the way of keeping things working on other "more supported" platforms.

It seems we can support it just with _comp_tail, so the maintenance cost seems small. If there are any problems, we may remove the wrapper _comp_tail together with _comp_awk to drop the support for Solaris.

The use of "sed 1d" has been replaced with "tail -n +2" in GitHub PR
1567, but it turned out that "tail" in Solaris 11.3 does not support
"tail -n +2", i.e., the POSIX option "-n" [1].  This patch tries to
fix up the uses of "tail" by introducing a compatibility wrapper for
"tail".

Solaris 11.3 provides a POSIX-compatible version of tail through
/usr/xpg4/bin/tail in a similar way as the POSIX-compatible version of
awk at /usr/xpg4/bin/awk.  We add a wrapper for "tail" in the same way
as we do for "awk".  To avoid aliases and shell functions of the same
name, the new wrapper also prefixes "command" to call "tail" in normal
environment.

The branch that had used "sed 1d" for Solaris is also selected in AIX.
This lead to a suspicion that AIX tail might also have a compatibility
issue [2].  According to the online manuals, the tail command in AIX
(at least >= 5.3) seems to support "-n +N" [3-5].

[1] \
scop#1567 (comment)
[2] \
scop#1567 (comment)
[3] AIX 5.3 (2004-08) \
http://public.dhe.ibm.com/systems/power/docs/aix/53/aixcmds5.pdf
[4] AIX 6.1 (2007-11) \
http://public.dhe.ibm.com/systems/power/docs/aix/61/aixcmds5_pdf.pdf
[5] AIX 7.3.0 (2021-12) \
https://www.ibm.com/docs/en/aix/7.3.0?topic=t-tail-command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant