zsh-users
 help / color / mirror / code / Atom feed
* RE: Help with functions
@ 2000-04-26 21:02 Cosgray, Nathan
  0 siblings, 0 replies; 7+ messages in thread
From: Cosgray, Nathan @ 2000-04-26 21:02 UTC (permalink / raw)
  To: zsh-users


I do see the following command in run_masterfile_step:

  this=`basename $0`

but no references at all to 'nofunctionargzero' in my init files.

-n.

-----Original Message-----
From: Thomas Köhler [mailto:jean-luc@picard.franken.de]
Sent: Wednesday, April 26, 2000 3:41 PM
To: zsh-users@sunsite.auc.dk
Subject: Re: Help with functions


Hi,

On Wed, Apr 26, 2000 at 10:28:34PM +0200,
Cosgray, Nathan <ncosgray@iupui.edu> wrote:
> 
> Hello everyone,
> 
> I am trying to run a complex group of processes that at one time were all
> automated via make, which called functions in a zsh shell script, which in
> turn moved files around and ran sas scripts.  All of this was written
years
> ago by the predecessor to the predecessor to my predecessor.  To my
> knowledge the last time they were used sucessfully was towards the end of
> 1998.
> 
> Here is the problem that seems to be holding me back.  To be as precise as
> possible, the makefile calls functions within a zsh script in the
following
> manner:
> 
>   <file1>:
>   	./run_masterfile_step get_file <param1> <param2>
>  
>   <file2>:
>   	./run_masterfile_step get_file <param3> <param4>
> 
>    <file3>:
>   	./run_masterfile_step recalcprep
> 
> Etc.  So, from my makefile, many different zsh functions are called to
> operate on many different files, according to the dependencies defined in
> the makefile and the parameters passed to the various functions in
> run_masterfile_step.
[...]

OK, the problem seems very strange, so here goes a _very_ wild guess:
Does "run_masterfile_step" evaluate $0 sometimes and there is now a
"setopt nofunctionargzero" somewhere in you .zshrc (or another
init-file) that wasn't there before?

CU,
Thomas

-- 
 Thomas Köhler Email:   jean-luc@picard.franken.de     | LCARS - Linux
     <><        WWW:     http://jeanluc-picard.de      | for Computers
                IRC:             jeanluc               | on All Real
               PGP public key available from Homepage! | Starships


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

* Re: Help with functions
  2000-04-27 20:18 Cosgray, Nathan
@ 2000-04-28 15:15 ` Oliver Kiddle
  0 siblings, 0 replies; 7+ messages in thread
From: Oliver Kiddle @ 2000-04-28 15:15 UTC (permalink / raw)
  To: Cosgray, Nathan; +Cc: zsh-users

Cosgray, Nathan wrote:
> 
> FYI, I have fixed this problem by adding the following line to the END of
> the script in question:
> 
>   $*
> 
> thus explicitly calling the function passed in the parameters to
> run_masterfile_step. It seems like a giant hack to me, but at least it
> works.

Sorry, I should have been clearer in my first reply. Putting the $* at
the end was significant because it needs to be after the functions are
defined otherwise the functions won't exist yet. In shell scripts,
functions are a bit like normal statements in that when control reaches
the line on which the function is defined, only then does the function
become defined. This means that you can do tricks like defining two
different versions of a function with the same name inside an if ...
then ... else.

I wouldn't call it a giant hack at all. I suspect that the $* was there
originally and got lost at some point.

> Where can I find documentation on '$@' and other such nifty things?

Have you got a copy of the manual somewhere? If not, you can browse the
HTML version on the zsh web pages at sunsite.auc.dk/zsh. There is a
section listing special parameters like $@ and $*. I would give you some
better references but I don't have access to the manual myself at the
moment. You may find the manual a bit heavy going so any book on UNIX
shell scripting will be mostly relevant to zsh scripts (but stick to
sections on the bourne/korn shells avoiding anything on the C-shell).

Oliver Kiddle



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

* RE: Help with functions
@ 2000-04-27 20:18 Cosgray, Nathan
  2000-04-28 15:15 ` Oliver Kiddle
  0 siblings, 1 reply; 7+ messages in thread
From: Cosgray, Nathan @ 2000-04-27 20:18 UTC (permalink / raw)
  To: zsh-users


FYI, I have fixed this problem by adding the following line to the END of
the script in question:

  $*

thus explicitly calling the function passed in the parameters to
run_masterfile_step. It seems like a giant hack to me, but at least it
works.

-n.


-----Original Message-----
From: Cosgray, Nathan 
Sent: Thursday, April 27, 2000 11:01 AM
To: zsh-users@sunsite.auc.dk
Subject: RE: Help with functions



I added the line as you suggested to the beginning of the
run_masterfile_step script:

  #!/usr/local/bin/zsh

  $@

  now()
  { echo "\c`date +%H:%M:%S` "; }
 
  ...

This makes no difference in its execution. The functions are still not being
run. Are there other ways to tell a zsh script to run a function?

Where can I find documentation on '$@' and other such nifty things?

-n.

-----Original Message-----
From: Oliver Kiddle [mailto:opk@u.genie.co.uk]
Sent: Wednesday, April 26, 2000 7:41 PM
To: Cosgray, Nathan
Cc: zsh-users@sunsite.auc.dk
Subject: Re: Help with functions


Cosgray, Nathan wrote:

> Here is the problem that seems to be holding me back.  To be as precise as
> possible, the makefile calls functions within a zsh script in the
following
> manner:
>   <file1>:
>         ./run_masterfile_step get_file <param1> <param2>

> The zsh script run_masterfile_step contains about 25 functions defined
like

> Now, I have never delved too deeply into shell scripting, but from what I
> can gather the idea behind this is that make calls the functions defined
in
> run_masterfile_step.

What is happening here is that make is calling the run_masterfile_step
script with a number of parameters, the first of which is 'get_file' or
the name of some function. This does not implicitly mean that the
get_file function will be run. My guess is that run_masterfile_step
contained a line which looked something like:

$@

and that this line has been lost. This line substitutes any parameters
so would run a function if the first parameter named one.

Oliver Kiddle




> 
> The problem is, none of this is working.  make fails due to the fact that
> none of the functions provided by run_masterfile_step actually do
anything.
> To experiment from the command line, I can type './run_masterfile_step
> <somefunction>' and nothing will happen (obviously I have closely examined
> the functions and I'm including valid parameters, referring to files that
> exist, etc.).  I get no error messges, no output (all of the functions
> within the zsh script use echo's extensively to give feedback), and I
notice
> no discernable processing time.  I can easily tell what is supposed to
> happen from the script code but none of it is in fact happening.  I can do
a
> 'source run_masterfile_step' and then type '<somefunction>' and it will
work
> properly, however.  So I'm thinking there must be a problem with the way
in
> which these functions are called.  Unfortunately, I can't find any
> documentation that describes the syntax and rules for this.  Does this
> problem have anything to do with the fact that these functions are
> indirectly called from make vs. from within zsh?  Should these functions
be
> split up into separate shell scripts?
> 
> We currently have zsh 3.0.2 installed on SunOS 5.5 and 5.6 (varies by
> machine).  I also compiled zsh 2.5.03 but it did not work as expected with
> these scripts, either.  I have no way of knowing what version of zsh
> orginally ran these scripts years ago.  I do know that they were used
> sucessfully for quite some time -- at least 3 years ending in November of
> 1998.  I believe there have been some hardware and software upgrades since
> then but I'm not sure what could cause these scripts to break in such a
> fundamental way.
> 
> I'm sure that I can rewrite or reorganize these scripts if I need to.  But
> I'd just like to make sure there is nothing I can do to easily fix this.
> I'm also extremely confused about why this would no longer be working the
> way it was written.  There must be something important I'm missing and I'd
> like to understand what that is.
> 
> So.  Any ideas or thoughts?  Corrections of syntax?  Version conflicts?
Do
> you need more information, like the scripts themselves?  Or at the least
can
> you tell me where to go for zsh scripting documentation more detailed and
> complete than the man pages or that kept on http://www.zsh.org?
> 
> Your help is very much appreciated.
> 
> Thanks
> 
> Nathan A. Cosgray, Database Administrator
> IUPUI Dept. of Medical Genetics


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

* RE: Help with functions
@ 2000-04-27 16:00 Cosgray, Nathan
  0 siblings, 0 replies; 7+ messages in thread
From: Cosgray, Nathan @ 2000-04-27 16:00 UTC (permalink / raw)
  To: zsh-users


I added the line as you suggested to the beginning of the
run_masterfile_step script:

  #!/usr/local/bin/zsh

  $@

  now()
  { echo "\c`date +%H:%M:%S` "; }
 
  ...

This makes no difference in its execution. The functions are still not being
run. Are there other ways to tell a zsh script to run a function?

Where can I find documentation on '$@' and other such nifty things?

-n.

-----Original Message-----
From: Oliver Kiddle [mailto:opk@u.genie.co.uk]
Sent: Wednesday, April 26, 2000 7:41 PM
To: Cosgray, Nathan
Cc: zsh-users@sunsite.auc.dk
Subject: Re: Help with functions


Cosgray, Nathan wrote:

> Here is the problem that seems to be holding me back.  To be as precise as
> possible, the makefile calls functions within a zsh script in the
following
> manner:
>   <file1>:
>         ./run_masterfile_step get_file <param1> <param2>

> The zsh script run_masterfile_step contains about 25 functions defined
like

> Now, I have never delved too deeply into shell scripting, but from what I
> can gather the idea behind this is that make calls the functions defined
in
> run_masterfile_step.

What is happening here is that make is calling the run_masterfile_step
script with a number of parameters, the first of which is 'get_file' or
the name of some function. This does not implicitly mean that the
get_file function will be run. My guess is that run_masterfile_step
contained a line which looked something like:

$@

and that this line has been lost. This line substitutes any parameters
so would run a function if the first parameter named one.

Oliver Kiddle




> 
> The problem is, none of this is working.  make fails due to the fact that
> none of the functions provided by run_masterfile_step actually do
anything.
> To experiment from the command line, I can type './run_masterfile_step
> <somefunction>' and nothing will happen (obviously I have closely examined
> the functions and I'm including valid parameters, referring to files that
> exist, etc.).  I get no error messges, no output (all of the functions
> within the zsh script use echo's extensively to give feedback), and I
notice
> no discernable processing time.  I can easily tell what is supposed to
> happen from the script code but none of it is in fact happening.  I can do
a
> 'source run_masterfile_step' and then type '<somefunction>' and it will
work
> properly, however.  So I'm thinking there must be a problem with the way
in
> which these functions are called.  Unfortunately, I can't find any
> documentation that describes the syntax and rules for this.  Does this
> problem have anything to do with the fact that these functions are
> indirectly called from make vs. from within zsh?  Should these functions
be
> split up into separate shell scripts?
> 
> We currently have zsh 3.0.2 installed on SunOS 5.5 and 5.6 (varies by
> machine).  I also compiled zsh 2.5.03 but it did not work as expected with
> these scripts, either.  I have no way of knowing what version of zsh
> orginally ran these scripts years ago.  I do know that they were used
> sucessfully for quite some time -- at least 3 years ending in November of
> 1998.  I believe there have been some hardware and software upgrades since
> then but I'm not sure what could cause these scripts to break in such a
> fundamental way.
> 
> I'm sure that I can rewrite or reorganize these scripts if I need to.  But
> I'd just like to make sure there is nothing I can do to easily fix this.
> I'm also extremely confused about why this would no longer be working the
> way it was written.  There must be something important I'm missing and I'd
> like to understand what that is.
> 
> So.  Any ideas or thoughts?  Corrections of syntax?  Version conflicts?
Do
> you need more information, like the scripts themselves?  Or at the least
can
> you tell me where to go for zsh scripting documentation more detailed and
> complete than the man pages or that kept on http://www.zsh.org?
> 
> Your help is very much appreciated.
> 
> Thanks
> 
> Nathan A. Cosgray, Database Administrator
> IUPUI Dept. of Medical Genetics


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

* Re: Help with functions
  2000-04-26 20:22 Cosgray, Nathan
  2000-04-26 20:41 ` Thomas Köhler
@ 2000-04-27  0:40 ` Oliver Kiddle
  1 sibling, 0 replies; 7+ messages in thread
From: Oliver Kiddle @ 2000-04-27  0:40 UTC (permalink / raw)
  To: Cosgray, Nathan; +Cc: zsh-users

Cosgray, Nathan wrote:

> Here is the problem that seems to be holding me back.  To be as precise as
> possible, the makefile calls functions within a zsh script in the following
> manner:
>   <file1>:
>         ./run_masterfile_step get_file <param1> <param2>

> The zsh script run_masterfile_step contains about 25 functions defined like

> Now, I have never delved too deeply into shell scripting, but from what I
> can gather the idea behind this is that make calls the functions defined in
> run_masterfile_step.

What is happening here is that make is calling the run_masterfile_step
script with a number of parameters, the first of which is 'get_file' or
the name of some function. This does not implicitly mean that the
get_file function will be run. My guess is that run_masterfile_step
contained a line which looked something like:

$@

and that this line has been lost. This line substitutes any parameters
so would run a function if the first parameter named one.

Oliver Kiddle




> 
> The problem is, none of this is working.  make fails due to the fact that
> none of the functions provided by run_masterfile_step actually do anything.
> To experiment from the command line, I can type './run_masterfile_step
> <somefunction>' and nothing will happen (obviously I have closely examined
> the functions and I'm including valid parameters, referring to files that
> exist, etc.).  I get no error messges, no output (all of the functions
> within the zsh script use echo's extensively to give feedback), and I notice
> no discernable processing time.  I can easily tell what is supposed to
> happen from the script code but none of it is in fact happening.  I can do a
> 'source run_masterfile_step' and then type '<somefunction>' and it will work
> properly, however.  So I'm thinking there must be a problem with the way in
> which these functions are called.  Unfortunately, I can't find any
> documentation that describes the syntax and rules for this.  Does this
> problem have anything to do with the fact that these functions are
> indirectly called from make vs. from within zsh?  Should these functions be
> split up into separate shell scripts?
> 
> We currently have zsh 3.0.2 installed on SunOS 5.5 and 5.6 (varies by
> machine).  I also compiled zsh 2.5.03 but it did not work as expected with
> these scripts, either.  I have no way of knowing what version of zsh
> orginally ran these scripts years ago.  I do know that they were used
> sucessfully for quite some time -- at least 3 years ending in November of
> 1998.  I believe there have been some hardware and software upgrades since
> then but I'm not sure what could cause these scripts to break in such a
> fundamental way.
> 
> I'm sure that I can rewrite or reorganize these scripts if I need to.  But
> I'd just like to make sure there is nothing I can do to easily fix this.
> I'm also extremely confused about why this would no longer be working the
> way it was written.  There must be something important I'm missing and I'd
> like to understand what that is.
> 
> So.  Any ideas or thoughts?  Corrections of syntax?  Version conflicts?  Do
> you need more information, like the scripts themselves?  Or at the least can
> you tell me where to go for zsh scripting documentation more detailed and
> complete than the man pages or that kept on http://www.zsh.org?
> 
> Your help is very much appreciated.
> 
> Thanks
> 
> Nathan A. Cosgray, Database Administrator
> IUPUI Dept. of Medical Genetics



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

* Re: Help with functions
  2000-04-26 20:22 Cosgray, Nathan
@ 2000-04-26 20:41 ` Thomas Köhler
  2000-04-27  0:40 ` Oliver Kiddle
  1 sibling, 0 replies; 7+ messages in thread
From: Thomas Köhler @ 2000-04-26 20:41 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 1694 bytes --]

Hi,

On Wed, Apr 26, 2000 at 10:28:34PM +0200,
Cosgray, Nathan <ncosgray@iupui.edu> wrote:
> 
> Hello everyone,
> 
> I am trying to run a complex group of processes that at one time were all
> automated via make, which called functions in a zsh shell script, which in
> turn moved files around and ran sas scripts.  All of this was written years
> ago by the predecessor to the predecessor to my predecessor.  To my
> knowledge the last time they were used sucessfully was towards the end of
> 1998.
> 
> Here is the problem that seems to be holding me back.  To be as precise as
> possible, the makefile calls functions within a zsh script in the following
> manner:
> 
>   <file1>:
>   	./run_masterfile_step get_file <param1> <param2>
>  
>   <file2>:
>   	./run_masterfile_step get_file <param3> <param4>
> 
>    <file3>:
>   	./run_masterfile_step recalcprep
> 
> Etc.  So, from my makefile, many different zsh functions are called to
> operate on many different files, according to the dependencies defined in
> the makefile and the parameters passed to the various functions in
> run_masterfile_step.
[...]

OK, the problem seems very strange, so here goes a _very_ wild guess:
Does "run_masterfile_step" evaluate $0 sometimes and there is now a
"setopt nofunctionargzero" somewhere in you .zshrc (or another
init-file) that wasn't there before?

CU,
Thomas

-- 
 Thomas Köhler Email:   jean-luc@picard.franken.de     | LCARS - Linux
     <><        WWW:     http://jeanluc-picard.de      | for Computers
                IRC:             jeanluc               | on All Real
               PGP public key available from Homepage! | Starships

[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]

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

* Help with functions
@ 2000-04-26 20:22 Cosgray, Nathan
  2000-04-26 20:41 ` Thomas Köhler
  2000-04-27  0:40 ` Oliver Kiddle
  0 siblings, 2 replies; 7+ messages in thread
From: Cosgray, Nathan @ 2000-04-26 20:22 UTC (permalink / raw)
  To: zsh-users


Hello everyone,

I am trying to run a complex group of processes that at one time were all
automated via make, which called functions in a zsh shell script, which in
turn moved files around and ran sas scripts.  All of this was written years
ago by the predecessor to the predecessor to my predecessor.  To my
knowledge the last time they were used sucessfully was towards the end of
1998.

Here is the problem that seems to be holding me back.  To be as precise as
possible, the makefile calls functions within a zsh script in the following
manner:

  <file1>:
  	./run_masterfile_step get_file <param1> <param2>
 
  <file2>:
  	./run_masterfile_step get_file <param3> <param4>

   <file3>:
  	./run_masterfile_step recalcprep

Etc.  So, from my makefile, many different zsh functions are called to
operate on many different files, according to the dependencies defined in
the makefile and the parameters passed to the various functions in
run_masterfile_step.

The zsh script run_masterfile_step contains about 25 functions defined like
so:

  #!/usr/local/bin/zsh

  ...

  get_file ()
  {
    ...
  }

  recalcprep ()
  {
    ...
  }

Now, I have never delved too deeply into shell scripting, but from what I
can gather the idea behind this is that make calls the functions defined in
run_masterfile_step.  In turn, the functions will perform various tasks
based on the parameters they receive.  In addition, these functions often
call each other, in order to do things such as display the current
date/time, or send an email message -- which is, I assume, partly why they
must all be contained within a single file.

The problem is, none of this is working.  make fails due to the fact that
none of the functions provided by run_masterfile_step actually do anything.
To experiment from the command line, I can type './run_masterfile_step
<somefunction>' and nothing will happen (obviously I have closely examined
the functions and I'm including valid parameters, referring to files that
exist, etc.).  I get no error messges, no output (all of the functions
within the zsh script use echo's extensively to give feedback), and I notice
no discernable processing time.  I can easily tell what is supposed to
happen from the script code but none of it is in fact happening.  I can do a
'source run_masterfile_step' and then type '<somefunction>' and it will work
properly, however.  So I'm thinking there must be a problem with the way in
which these functions are called.  Unfortunately, I can't find any
documentation that describes the syntax and rules for this.  Does this
problem have anything to do with the fact that these functions are
indirectly called from make vs. from within zsh?  Should these functions be
split up into separate shell scripts?

We currently have zsh 3.0.2 installed on SunOS 5.5 and 5.6 (varies by
machine).  I also compiled zsh 2.5.03 but it did not work as expected with
these scripts, either.  I have no way of knowing what version of zsh
orginally ran these scripts years ago.  I do know that they were used
sucessfully for quite some time -- at least 3 years ending in November of
1998.  I believe there have been some hardware and software upgrades since
then but I'm not sure what could cause these scripts to break in such a
fundamental way.

I'm sure that I can rewrite or reorganize these scripts if I need to.  But
I'd just like to make sure there is nothing I can do to easily fix this.
I'm also extremely confused about why this would no longer be working the
way it was written.  There must be something important I'm missing and I'd
like to understand what that is.

So.  Any ideas or thoughts?  Corrections of syntax?  Version conflicts?  Do
you need more information, like the scripts themselves?  Or at the least can
you tell me where to go for zsh scripting documentation more detailed and
complete than the man pages or that kept on http://www.zsh.org?

Your help is very much appreciated.

Thanks

Nathan A. Cosgray, Database Administrator
IUPUI Dept. of Medical Genetics



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

end of thread, other threads:[~2000-04-30 13:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-04-26 21:02 Help with functions Cosgray, Nathan
  -- strict thread matches above, loose matches on Subject: below --
2000-04-27 20:18 Cosgray, Nathan
2000-04-28 15:15 ` Oliver Kiddle
2000-04-27 16:00 Cosgray, Nathan
2000-04-26 20:22 Cosgray, Nathan
2000-04-26 20:41 ` Thomas Köhler
2000-04-27  0:40 ` Oliver Kiddle

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).