Since upgrading to OS X 10.5 the TM_USERNAME variable used in bundles has been unset.
The following command is the problem:
TM_USERNAME=`niutil -readprop / /users/$USER realname`
Seems that the niutil command has been dropped from 10.5 onwards and replaced by the dscl command.
The following gets the current users real name but prepends it with the property key:
dscl . -read /Users/$USER RealName
returns: RealName: John Hunter
I'm not sure how you get the value without the key.
Has anyone got a solution to this? It affects most of the templates.
Apologies if its been covered before.
Thanks --John
On 29/11/2007, Kai Janson kaijanson@thejeeper.net wrote:
dscl . -read /Users/$USER RealName |sed -e "s/RealName://" -e "s/^ \ //" | tail -1
I don't understand why that can't just be
dscl . -read /Users/$USER RealName |sed 's/RealName: //'
?
Or an alternative approach:
perl -le 'print +(getpwuid $<)[6]'
Robin
Are you sure? There isn't one on my computer; though I'm still running 10.4, so it could be different.
(You noticed that I added a space after the colon in the regular expression?)
Robin
On 29/11/2007, Kai Janson kaijanson@thejeeper.net wrote:
Yes, I am running Leopard 10.5.1 and there is actually a white space in front of the name. I assume that your dscl . -read /Users/$USER RealName |sed 's/ RealName: //' works on Tiger but it does not work on Leopard.
There is no trailing white space on Leopard, thus it fails to sed anything. The technique I use is overkill. I could have used
dscl . -read /Users/$USER RealName | tail -1
but then I would end up with the name plus a leading white space.
dscl . -read /Users/$USER RealName | tail -1 | sed -e "s/^\ //"
That line fishes the real name out of dscl's database, then eliminates the first line altogether and finally removes the leading white space if there is one.
Here a snippet from my shell:
mac-mini-intel:Tasks kjanson$ res=`dscl . -read /Users/$USER RealName | tail -1` mac-mini-intel:Tasks kjanson$ echo "'$res'" ' Kai Janson' mac-mini-intel:Tasks kjanson$ res=`dscl . -read /Users/$USER RealName | tail -1 | sed -e "s/^\ //"` mac-mini-intel:Tasks kjanson$ echo "'$res'" 'Kai Janson'
--Kai
On Nov 29, 2007, at 10:58 AM, Robin Houston wrote:
On 29/11/2007, Kai Janson kaijanson@thejeeper.net wrote:
Yes, I am running Leopard 10.5.1 and there is actually a white space in front of the name.
Wow, that's awful. Thanks. Why is it that Apple are so dreadful at making command-line tools that work in a sensible way?
If we need to do this (and Peter's comment is making me wonder whether or not we do), then at least
perl -le 'print +(getpwuid $<)[6]'
is portable and concise (and not likely to break when Apple change their bizarre tool in yet another incompatible way).
Robin
On 29 Nov 2007, at 19:19, Robin Houston wrote:
From the r1431 release notes:
[NEW] TextMate sets TM_FULLNAME (unless you set it yourself) to the user’s full name, so no longer necessarily to fiddle with niutil and dscl to obtain it.
So it should not be necessary for commands/snippets to try and obtain the full username themselves.