I noticed a subtle difference between the command posted:
echo $(id -un)
and the error message for it:
id: –un: No such user
The two "hyphens" are different, the second one being a tiny bit longer. It looks like the error message was copied and pasted from the original, but the command was re-typed. The original command most likely contains the wrong kind of hyphen. This explains why no one could reproduce the error message.
This kind of error mostly has one of two reasons:
Code was copied from websites, where it was typeset using a bad formatter / syntax highlighter.
Code was typed in an inappropriate editing environment, like Microsoft Word. Word might change something you type into a typographical better, but unexpected variant, like different hyphens, different quotes, or some other space sign.
Coincidentally, there was just a popularity contest challenge on Codegolf, where one answer used a similar "trick" to yield a difference that was not even visible: https://codegolf.stackexchange.com/a/23258/16287
$(id -un)
with$(/usr/bin/id -un)