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

Re: simplify and if then else



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
> 
> -- 
> zzapper
> http://www.successtheory.com/tips/vimtips.html
> 
> 
> 
> 
>  To report this email as spam click https://www.mailcontrol.com/sr/B4ikS7CuQx
> HTndxI!oX7UpIgRUnoDh5vM4IlkUtlbP1h3mjxHrJheu1GxnkVntZMuoKbcOI0SxgpdY6WjzZSeg=
> = .

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}

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070



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