Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: simplify and if then else



2008/9/24 Peter Stephenson <pws@xxxxxxx>:
> zzapper wrote:
>> Hi
>> Having a Homer Simpson moment, but this must be easy to simplify
>> if [[ "$LOGNAME" != davidr ]]
>> then
>> cd /o/inetpub/wwwdev/www.some.co.uk/epsystem/epadmin
>> else
>> cd /c/inetpub/wwwdev/www.some.co.uk/epsystem/epadmin
>> fi
>>
> cd \
> ${${${LOGNAME:#davidr}:+/o}:-/c}/inetpub/wwwdev/www.some.co.uk/epsystem/epadmin
>
> although if LOGNAME is empty it's treated the same as if it were davidr;
> if that's an issue it gets even more clumsy:
>
> ${${${${LOGNAME:-x}:#davidr}:+/o}:-/c}

A bit longer but arguably still simpler :)
cd /$([[ "$LOGNAME" != davidr ]] && echo o || echo c)/inetpub/wwdev/blabla

-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author