readlink man/help does not match command flags

Asked by jpvrlaone on 2012-05-12

I stumlbed accross a problem where a script kept failing when running the readlink command.
It did not like the use of the -f flag which is supported in the man page. I got past the problem using /usr/lib/klibc/bin/readlink found through a search of the system. More details can be found in the forum using the tag "readlink".
What is going on with the readlink command?

Ubuntu 12.04 (precise)
Intel(R) Core(TM) i5 CPU 650 @ 3.20GHz

Question information

English Edit question
Ubuntu coreutils Edit question
No assignee Edit question
Solved by:
Last query:
Last reply:

I suggest you report a bug

You should also reboot to the Precise kernel, your kernel version is not that of Precise.

I use readlink often, including -f, and have found no problems with it. Please link to the forum discussion.

jpvrlaone (jpv4433) said : #3

I updated my kernel earlier but I see what is going on now. When I test readlink from the command line as a non-root user (readlink -f "$0") the dollar zero passes"-bash" as a value where the first letter after the dash is "b" and is considered an invalid flag. Likewise, when this is done as root the dollar zero passes "-su" where "s" is accepted since it is valid but the "u" is not. So apparently the problem stems from the use of $0 when used within a script as opposed to a command line.
I would like to rerun the original install script to see why it was failing at the readlink juncture but I "prefer to let sleeping dogs lie".

Linux XXXxxxx 3.2.0-24-generic #37-Ubuntu SMP Wed Apr 25 08:43:22 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

[ user ~ ] $ echo "$0"
[ user ~ ] $ readlink -f "$0"
readlink: invalid option -- 'b'
Try `readlink --help' for more information.

[ user ~ ] $ su -
root@pc:~# echo "$0"
root@pc:~# readlink -f "$0"
readlink: invalid option -- 'u'
Try `readlink --help' for more information.
root@pc:~# man readlink

I suggest you re-disable the root account and stick to sudo