Description of Problem: In the last phase of RPM building 'rpm -ba' gives error message: head: invalid option -- 1 Try `head --help' for more information. Version-Release number of selected component (if applicable): rpm-4.0.3-1.03 and rpm-build-4.0.3-1.03 How Reproducible: Often. Steps to Reproduce: 1. rpm -ba tetex.spec (for instance) Actual Results: head: invalid option -- 1 Try `head --help' for more information. Often many, many repeats... Expected Results: At least not this error message ;-) Additional Information: My '/usr/bin/head' is from 'textutils-2.0.14-2' (standard RedHat 7.2 issue). If we change 4 occurrences of 'tail -1' into 'tail --lines=1' in the files /usr/lib/rpm/find-requires /usr/lib/rpm/config.guess /usr/lib/rpm/find-requires.perl the error messages go away. NOTE: According to a quick search, there are many other packages that suffer from this problem: root@Helix:~# cat /etc/redhat-release Red Hat Linux release 7.2 (Enigma) root@Helix:~# rpm -qf `grep -rl 'head -1' /usr/bin` gnome-libs-1.2.13-16 mutt-1.2.5.1-1 netscape-common-4.78-2 netscape-communicator-4.78-2 postgresql-server-7.1.3-2 wine-20010822-1 enlightenment-0.16.4-11 netscape-navigator-4.78-2 fvwm-themes-base-0.6.0-1
I'm not sure what to tell you, as I build daily using head(1) from the 7.2 textutils package without problem. Can you provide more information?
I've turned my system upside-down and found that it is indeed a problem with my system. 'which head' returns '/usr/bin/head'. RedHat 7.2 aliasses 'which' (in /etc/profile.d/which-2.sh) to 'alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'. This alias also only returned the expected '/usr/bin/head'. Bash' 'type -all head' on the other hand, also found a bash function that redefined 'head' to 'head () { command head --lines=30 "$@" }', obviously to extract a few more lines than the default 10. This knit was hiding in '/root/.bashrc'. That happens if you copy rc-files from an old system to the new one ;-) The '-1' switch that RedHat's 'rpm' uses does work, but only if it is the only or the first option. '/usr/bin/head -1 /etc/passwd' works '/usr/bin/head -1 -v /etc/passwd' works too, but '/usr/bin/head -v -1 /etc/passwd' does not. So the '-1' option is breakable. '/usr/bin/head --lines=1 --verbose /etc/passwd' works. '/usr/bin/head --verbose --lines=1 /etc/passwd' works. So the '--lines=1' option seem more robust that the '-1' option. The "bug" was the fact that I added an option before the '-1' in the function. So to get rid of it on my system only needed getting rid op the function and the change from '-1' to '--lines=1' was not really needed. My 'build' broke because '/usr/bin/head --lines=30 -1 /etc/passwd' does not work. My solution of using the '--lines=1' option worked because '/usr/bin/head --lines=30 --lines=1 /etc/passwd' does give the required result (one line) and not an error message. Although the fault turned out to be mine, I would nevertheless prefer to use '--lines=1' given the fact that is is apparently more robust. Using '-n 1' works as well as '--lines=1'. I hope this time my testing was more thorough... I'll rename my 'head' function to 'h30' ;-)
While I can appreciate your pain in debugging, the underlying problem is that of shell aliases are kinda borken in unix. Even though I can contemplate "hardening" of rpm scripts to avoid the problem by either 1) using the long option variant (as you've suggested) 2) hardwiring a /usr/bin/head path to avoid aliases I don't believe that the effort is worthwhile: there's no clear win AFAICT, it's just life with unix shell.