Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: alias with a parameter
On 07 Apr 2021, at 01:05, Stephane Chazelas <stephane@xxxxxxxxxxxx> wrote:
> 2021-04-05 20:47:47 -0600, Grant Taylor:
> [...]
>> pd() {
>> [ -n "${1}" ] && pushd "${1}" || popd;
>> }
>>
>> It's using parameters on a function, just like you're trying to do. It
>> works a treat.
>>
>> Aside: Yes, I'm lazy and don't want to type pushd or popd. Instead, the pd
>> function determines which command to run based on if $1 is set or not.
> [...]
>
> That function would run popd when pushd fails. It's generally a
> bad idea to use this kind of a && b || c in place of proper
> if/then/else constructs.
Bad idea, or just a style "this is proper practice" sort of thing?
I can't imagine any 'bad idea' from this, as it is doing the same basic thing.
--
ɹןʇnqן
<mailto:lbutler@xxxxxxxxxx>
tel:+1.303.219.0564
Messages sorted by:
Reverse Date,
Date,
Thread,
Author