1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Fix regression in handling of head builtin's -s flag (re: 4ca578bd) (#514)

Commit 4ca578bd accidentally left in half of an if statement that was
originally just a use of the SFMTXBEGIN2 macro (which is a no-op without
vt_threaded). As a result, the head builtin's -s flag broke in one of
the ksh2020 regression tests. Reproducer:
   # Note that head must be enabled in src/cmd/ksh93/data/builtins.c
   builtin head || exit 1
   cat > "/tmp/file1" <<EOF
This is line 1 in file1
This is line 2 in file1
This is line 3 in file1
This is line 4 in file1
This is line 5 in file1
This is line 6 in file1
This is line 7 in file1
This is line 8 in file1
This is line 9 in file1
This is line 10 in file1
This is line 11 in file1
This is line 12 in file1
EOF
   got=$(head -s 5 -c 18 "/tmp/file1")
   exp=$'is line 1 in file1'
   [[ "$got" = "$exp" ]] || print "'head -s' failed" "(expected $(printf %q "$exp"), got $(printf %q "$got"))"

Code change that caused this bug (note that since the if statement
wasn't completely removed, it now guards the for loop despite the
newline):
        if(fw)
-               SFMTXBEGIN2(fw, (Sfoff_t)0);

        for(n_move = 0; n != 0; )

I noticed this since I'm making a separate commit to backport more of
the ksh2020 regression tests.

src/lib/libast/sfio/sfmove.c:
- Remove the incomplete if statement to fix the -s flag.

src/cmd/ksh93/tests/b_head.sh:
- Backport the ksh2020 regression tests for the head builtin.
This commit is contained in:
Johnothan King 2022-08-16 14:44:26 -07:00 committed by Martijn Dekker
parent f039e4115c
commit 4e18d65894
3 changed files with 96 additions and 1 deletions

3
NEWS
View file

@ -9,6 +9,9 @@ Uppercase BUG_* IDs are shell bug IDs as used by the Modernish shell library.
history expansion. (On 2022-01-24 the history comment character was set to
'#' instead of being disabled by default, which exposed this bug.)
- Fixed a bug introduced on 2022-02-12 that would cause the optional head
builtin's -s option to fail.
2022-08-08:
- Release 1.0.2.