Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Creating function in zsh
- X-seq: zsh-users 13338
- From: czech@xxxxxxxxx
- To: "Stephane Chazelas" <Stephane_Chazelas@xxxxxxxx>
- Subject: Re: Creating function in zsh
- Date: Thu, 16 Oct 2008 13:59:38 -0700 (PDT)
- Cc: zsh-users@xxxxxxxxxx
- Importance: Normal
- In-reply-to: <20081016201154.GC4773@xxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <5956.148.87.1.170.1224187179.squirrel@xxxxxxxxxxxxxxxxx> <20081016201154.GC4773@xxxxxxxxxxxxxxx>
Tried both the ";" and "&&".
Both work.
Thanks very much.
Corwin
> On Thu, Oct 16, 2008 at 12:59:39PM -0700, czech@xxxxxxxxx wrote:
>> Hi -
>>
>> I have created the following function in zsh on Mac OSX:
>>
>> cd() {
>> builtin cd "$@" print -D $PWD
>> }
>>
>> This works find on OSX, but gives the following error on Fedora Core 8:
>>
>> johann:czechar:.zfunc> cd /home/czechar
>> cd /home/czechar
>> cd:cd:1: too many arguments
>>
>> I am running zsh 4.2.6 on Fedora.
>>
>> Any notion what the problem could be?
> [...]
>
> I doubt it works on MaxOSX. You're not separating the two
> commands, so "print", "-D" and $PWD are treated as arguments to
> "builtin cd".
>
> cd() {
> builtin cd "$@" &&
> print -rD $PWD
> }
>
> "&&" as you probably want to print the current directory only if
> cd succeeds.
>
> You need -r, as you don't want \x sequences to be expanded.
>
> If you want to print the directory regardless of whether cd
> succeeds, you should at least make sure you return cd's exit
> status:
>
> cd() {
> local ret
> builtin cd "$@"
> ret=$?
> print -rD $PWD
> return $ret
> }
>
> --
> Stéphane
>
>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author