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

Re: alias with a parameter



Grant Taylor wrote on Sat, Apr 10, 2021 at 10:30:21 -0600:
> On 4/9/21 4:49 PM, Daniel Shahaf wrote:
> > Yet another variant:
> > 
> > pd() case $+1 in (0) popd;; (1) pushd "$1";; esac
> 
> Why use "$+1"?  I would have thought to use "$#" instead.
> 
> > Or if golfing:
> > 
> > pd()$# $1;0()popd;1()pushd $1
> 
> I feel like this is going outside the box.  If I'm interpreting it
> correctly, it's actually defining three functions; pd, 0, and 1, each of
> which do a teeny tiny piece / sub-function.  Wherein pd calls either 0 or 1
> + first argument.

Correct.

> Aside:  If I was going to do this, [...]

It wasn't meant to be used as production code.

Daniel




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