[TxMt] TM_USERNAME is null on Leopard

Kai Janson kaijanson at thejeeper.net
Thu Nov 29 17:32:43 UTC 2007


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:

> 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 at thejeeper.net> wrote:
>> There is a leading whitespace
>>
>> On Nov 29, 2007, at 8:14 AM, Robin Houston wrote:
>>
>>> On 29/11/2007, Kai Janson <kaijanson at 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
>>>
>>> ______________________________________________________________________
>>> For new threads USE THIS: textmate at lists.macromates.com
>>> (threading gets destroyed and the universe will collapse if you  
>>> don't)
>>> http://lists.macromates.com/mailman/listinfo/textmate
>>
>>
>> ______________________________________________________________________
>> For new threads USE THIS: textmate at lists.macromates.com
>> (threading gets destroyed and the universe will collapse if you  
>> don't)
>> http://lists.macromates.com/mailman/listinfo/textmate
>>
>
> ______________________________________________________________________
> For new threads USE THIS: textmate at lists.macromates.com
> (threading gets destroyed and the universe will collapse if you don't)
> http://lists.macromates.com/mailman/listinfo/textmate

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20071129/ae29f484/attachment.html>


More information about the textmate mailing list