-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Compatibility risks
tail
-
Obsolete numeric option:
tail -1(without-n) is a GNU-accepted historical shorthand. Some uutils/coreutils releases did not accept this shorthand. -
Concatenated form:
tail -n+2(no space) is accepted by GNU tail; uutils tail historically required the POSIX form with a space (tail -n +2). Newer uutils likely accept both.
head
head -n 1is standard and supported by both GNU and Rust coreutils. GNU also accepts the historical shorthandhead -1(without-n); uutils historically did not accept the obsolete numeric form in some releases.
The flow script and Makefile use -n1, so it’s fine. test.butt combines head -n1 (without space) with head -13 etc. (without -n).
Command line argument parsing in uutils
The uutils coreutils project (which includes utilities like uu_head and uu_tail) does use the clap crate for command-line argument parsing. The option -1 (and similarly -2, -3, …) is treated as a legacy POSIX/GNU shortcut, meaning:
-<number> ≡ -n <number>
This behavior is implemented intentionally in the parse_obsolete function in uucore where the digit options are intercepted and translated into -n, not provided automatically by clap. One may expect obsolete and legacy code removed in a future release.
Suggestions
- Use
tail -n 1(with space) andtail -n +2(with space) for maximum portability across uutils versions. - Prefer
head -n 13(with space) across all files for consistency and maximum portability.