RTEMS | shell: port the head command in the shell (!1061)
Mostafa Abdelglel (@galelo04)
gitlab at rtems.org
Fri Feb 13 18:08:57 UTC 2026
Mostafa Abdelglel created a merge request: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1061
Project:Branches: galelo04/rtems:shell-add-support-for-head-command to rtems/rtos/rtems:main
Author: Mostafa Abdelglel
## Summary
shell: Port the head command from FreeBSD
- port the head command from the FreeBSD source code
- port expand_number() to support SI suffixes
- port getline() from NetBSD ( #define _GNU_SOURCE didn't work )
- add necessary build support
verification:
verified manually on the sparc-rtems7-sis simulator.
I adapted some of the test cases from the FreeBSD test suite (tests/head_test.sh) and verified the output matches the host head command.
- default no options: head file (10 lines).
- line count: head -n 5 file.
- byte count: head -c 5 file
- SI units: head -n 1k file
- multiple files: head file1 file2 (verified that it produces headers without the -q flag)
- verbose flag: head -v file
- illegal line count: head -n fj file
- missing line count: head -n file
references:
- [FreeBSD head source code](https://github.com/freebsd/freebsd-src/blob/main/usr.bin/head/head.c)
- [FreeBSD head test suite](https://github.com/freebsd/freebsd-src/blob/main/usr.bin/head/tests/head_test.sh)
- [FreeBSD expand_number() source code](https://github.com/freebsd/freebsd-src/blob/main/lib/libutil/expand_number.c)
- [NetBSD getline() source code](https://github.com/lattera/freebsd/blob/master/contrib/file/getline.c)
## Generative AI
<!--Default settings, if it is a dropdown it will set after submission-->
--
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1061
You're receiving this email because of your account on gitlab.rtems.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20260213/df026958/attachment.htm>
More information about the bugs
mailing list