fix: add compatibility wrapper for tail#1572
Open
akinomyoga wants to merge 2 commits intoscop:mainfrom
Open
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes the uses of
tail -n +2in Solaris mentioned in #1567 (comment).See the commit message of 994dfde for details.
Yeah, I noticed the difference in the style. Technically, both
-n +2and-n+2should be supported based on POSIX, but it would be better to normalize the style in the codebase. I changed it in commit 994dfde.I also checked the online manuals of AIX, but AIX tail seems to be fine; it supports the option
-n +<num>.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_tailtogether with_comp_awkto drop the support for Solaris.