zsh-users
 help / color / mirror / code / Atom feed
* forbidden variable in for loop.
@ 2012-12-19 15:22 Ray Andrews
  2012-12-19 23:58 ` Danek Duvall
  2012-12-20  0:04 ` forbidden variable in for loop Frank Terbeck
  0 siblings, 2 replies; 8+ messages in thread
From: Ray Andrews @ 2012-12-19 15:22 UTC (permalink / raw)
  To: zsh-users

Gentlemen,

   for a in *; do echo $a; done

All fine. but:

   for i in *; do echo $i; done

Gives me a list of zeros. Followed by "zsh: bad floating point constant"

It works fine for any letter of the alphabet so far tested except 'i'.  
For the life of me I can't guess what it is that makes 'i' special. Any 
thoughts?


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: forbidden variable in for loop.
  2012-12-19 23:58 ` Danek Duvall
@ 2012-12-19 16:03   ` Ray Andrews
  2012-12-20  6:44     ` Function not found czech
  0 siblings, 1 reply; 8+ messages in thread
From: Ray Andrews @ 2012-12-19 16:03 UTC (permalink / raw)
  To: Danek Duvall, zsh-users

On 19/12/12 03:58 PM, Danek Duvall wrote:
> Ray Andrews wrote:
>
>>    for a in *; do echo $a; done
>>
>> All fine. but:
>>
>>    for i in *; do echo $i; done
>>
>> Gives me a list of zeros. Followed by "zsh: bad floating point constant"
>>
>> It works fine for any letter of the alphabet so far tested except
>> 'i'.  For the life of me I can't guess what it is that makes 'i'
>> special. Any thoughts?
> You probably did a "typeset -E i" at some point in the past.  "unset i"
> should get it working again.
>
> Danek
>
That did it Danek, thanks very much. I have no idea how that happened, 
but I guess it did.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: forbidden variable in for loop.
  2012-12-19 15:22 forbidden variable in for loop Ray Andrews
@ 2012-12-19 23:58 ` Danek Duvall
  2012-12-19 16:03   ` Ray Andrews
  2012-12-20  0:04 ` forbidden variable in for loop Frank Terbeck
  1 sibling, 1 reply; 8+ messages in thread
From: Danek Duvall @ 2012-12-19 23:58 UTC (permalink / raw)
  To: Ray Andrews; +Cc: zsh-users

Ray Andrews wrote:

>   for a in *; do echo $a; done
> 
> All fine. but:
> 
>   for i in *; do echo $i; done
> 
> Gives me a list of zeros. Followed by "zsh: bad floating point constant"
> 
> It works fine for any letter of the alphabet so far tested except
> 'i'.  For the life of me I can't guess what it is that makes 'i'
> special. Any thoughts?

You probably did a "typeset -E i" at some point in the past.  "unset i"
should get it working again.

Danek


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: forbidden variable in for loop.
  2012-12-19 15:22 forbidden variable in for loop Ray Andrews
  2012-12-19 23:58 ` Danek Duvall
@ 2012-12-20  0:04 ` Frank Terbeck
  1 sibling, 0 replies; 8+ messages in thread
From: Frank Terbeck @ 2012-12-20  0:04 UTC (permalink / raw)
  Cc: zsh-users

Ray Andrews wrote:
>   for i in *; do echo $i; done
>
> Gives me a list of zeros. Followed by "zsh: bad floating point constant"
>
> It works fine for any letter of the alphabet so far tested except 'i'.  For the
> life of me I can't guess what it is that makes 'i' special. Any thoughts?

  print ${(t)i}

I bet there's an `integer in there for `i' but not for `a'.

Regards, Frank


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Function not found
  2012-12-19 16:03   ` Ray Andrews
@ 2012-12-20  6:44     ` czech
  2012-12-20  9:03       ` Brandon Sandrowicz
  2012-12-20 11:02       ` Jérémie Roquet
  0 siblings, 2 replies; 8+ messages in thread
From: czech @ 2012-12-20  6:44 UTC (permalink / raw)
  To: zsh-users

Greetings!

I have a function I use to connect to remote hosts. I call my function _ssh:

_ssh() {
    ssh -XC "czechar@$@"
}

I keep my functions in a directory under my home dir. I call the directory
.zfuncs. I read my functions in my .zshrc via autoload and add them to my
fpath:

autoload -- ~/.zfunc/[^_]*(:t)
fpath=( ~/.zfunc $fpath )

But when I try to use _ssh, zsh tells me:

Grendel:czech:~> _ssh adc2201650
zsh: correct '_ssh' to 'ssh' [nyae]?

I thought I had told zsh not to correct my spelling for ssh via:

alias ssh='nocorrect ssh'

The function was working without issue until I ran compinstall. I have
commented out the lines added to my .zshrc by compinstall, but the problem
persists.

Any ideas on what the problem is here?

Thanks in advance.



Corwin


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Function not found
  2012-12-20  6:44     ` Function not found czech
@ 2012-12-20  9:03       ` Brandon Sandrowicz
  2012-12-20 11:02       ` Jérémie Roquet
  1 sibling, 0 replies; 8+ messages in thread
From: Brandon Sandrowicz @ 2012-12-20  9:03 UTC (permalink / raw)
  To: czech; +Cc: zsh-users

On Wed, Dec 19, 2012 at 10:44:23PM -0800, czech@sonic.net wrote:
> Greetings!
> 
> I have a function I use to connect to remote hosts. I call my function _ssh:
> 
> _ssh() {
>     ssh -XC "czechar@$@"
> }
> 
> I keep my functions in a directory under my home dir. I call the directory
> .zfuncs. I read my functions in my .zshrc via autoload and add them to my
> fpath:
> 
> autoload -- ~/.zfunc/[^_]*(:t)
> fpath=( ~/.zfunc $fpath )

The autoload command you have here appears to be your problem. You
probably want something like:

    autoload _ssh
    fpath=( ~/.zfunc $fpath )

If your _ssh function is defined in the file ~/.zfunc/_ssh, your
original command *could* work, but you would have to remove the '[^_]'
which prevents files beginning with underscores.

To be clear, autoload wants the names of the *functions*, not the names
of the files. Your approach above could work so long as each function is
in a separate file, and both (file and function) share the same exact
name (i.e. can't be _ssh.zsh).

> But when I try to use _ssh, zsh tells me:
> 
> Grendel:czech:~> _ssh adc2201650
> zsh: correct '_ssh' to 'ssh' [nyae]?
> 
> I thought I had told zsh not to correct my spelling for ssh via:
> 
> alias ssh='nocorrect ssh'

I think that you have the wrong idea here. From my reading of the
manpage, nocorrect only disables correction for the current command.
What you're attempting to do with it, would have to be accomplished by:

    alias _ssh='nocorrect _ssh'

E.g.:

    $ function _ssh() { echo "HERE"; }
    $ alias _ssh='nocorrect _ssh'
    $ _ssh
    HERE

Now when you run the _ssh function, the alias will expand the call to
"nocorrect _ssh" forcing auto-correct to ignore '_ssh'.

> The function was working without issue until I ran compinstall. I have
> commented out the lines added to my .zshrc by compinstall, but the problem
> persists.
> 
> Any ideas on what the problem is here?
> 
> Thanks in advance.
> 
> 
> 
> Corwin

Disclaimer: I know none of this for sure as I don't use CORRECT or my own
autoloads/fpath. I just gleaned this from the manpages, and poking at it
in a shell, so it's entirely possible that I don't know what I'm talking
about as I'm no zshell wizard.
-- 
Brandon Sandrowicz


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Function not found
  2012-12-20  6:44     ` Function not found czech
  2012-12-20  9:03       ` Brandon Sandrowicz
@ 2012-12-20 11:02       ` Jérémie Roquet
  2012-12-21 18:11         ` Bart Schaefer
  1 sibling, 1 reply; 8+ messages in thread
From: Jérémie Roquet @ 2012-12-20 11:02 UTC (permalink / raw)
  To: czech; +Cc: zsh-users

Hi Corwin,

2012/12/20  <czech@sonic.net>:
> I have a function I use to connect to remote hosts. I call my function _ssh:
>
> _ssh() {
>     ssh -XC "czechar@$@"
> }

Not sure it's related to you problem, but functions the name of which
starts with an underscore are usually completion functions for zsh.
For example, _ssh would handle the completion of the ssh command.

> I thought I had told zsh not to correct my spelling for ssh via:
>
> alias ssh='nocorrect ssh'

Yes, but you've told it not to do this for this command only, not for
the _ssh command.

Anyway, you should not have to do such things — having an alias would
be enough to prevent zsh from correcting the command, while still
allowing it to correct the rest of the command line.

Have you tried to run the “rehash” command?

Best regards,

-- 
Jérémie


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Function not found
  2012-12-20 11:02       ` Jérémie Roquet
@ 2012-12-21 18:11         ` Bart Schaefer
  0 siblings, 0 replies; 8+ messages in thread
From: Bart Schaefer @ 2012-12-21 18:11 UTC (permalink / raw)
  To: zsh-users

On Dec 20,  4:03am, Brandon Sandrowicz wrote:
}
} On Wed, Dec 19, 2012 at 10:44:23PM -0800, czech@sonic.net wrote:
} > 
} > _ssh() {
} >     ssh -XC "czechar@$@"
} > }
} > 
} > autoload -- ~/.zfunc/[^_]*(:t)
} > fpath=( ~/.zfunc $fpath )
} 
} The autoload command you have here appears to be your problem.
} 
} If your _ssh function is defined in the file ~/.zfunc/_ssh, your
} original command *could* work, but you would have to remove the '[^_]'
} which prevents files beginning with underscores.

My guess is that the [^_] was copied from a recipe related to the
completion system.  In most cases (as Jeremie later mentioned) any
file with a leading underscore in its name would contain a completion
function of some kind, and would therefore have a "#compdef" line at
the top.  These files are autoloaded by the compinit command (if the
$fpath is properly set when compinit is run) and therefore don't need
to be autoloaded a second time from .zshrc.
 
} To be clear, autoload wants the names of the *functions*, not the names
} of the files. Your approach above could work so long as each function is
} in a separate file, and both (file and function) share the same exact
} name (i.e. can't be _ssh.zsh).

To be even more specific, autoload depends upon the names of the files
being the *same* as the names of the functions.  Generally, the file
should contain only the function body, not the func() { ... } syntax.
If that syntax is used in the file, you need "autoload -k".  There are
exceptions, and reasons for a file to contain more than one function,
but you should avoid that until you understand the operation in detail.

-- 
Barton E. Schaefer


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-12-21 18:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-19 15:22 forbidden variable in for loop Ray Andrews
2012-12-19 23:58 ` Danek Duvall
2012-12-19 16:03   ` Ray Andrews
2012-12-20  6:44     ` Function not found czech
2012-12-20  9:03       ` Brandon Sandrowicz
2012-12-20 11:02       ` Jérémie Roquet
2012-12-21 18:11         ` Bart Schaefer
2012-12-20  0:04 ` forbidden variable in for loop Frank Terbeck

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).