zsh-workers
 help / color / mirror / code / Atom feed
* returning a pathname from a function
@ 2000-03-30 20:56 Allen Belk
  2000-03-31  5:47 ` Andrej Borsenkow
  0 siblings, 1 reply; 2+ messages in thread
From: Allen Belk @ 2000-03-30 20:56 UTC (permalink / raw)
  To: zsh-workers

Zsh hackers,
    I am attempting to return a path name from the following function.

prep_directories()
{
   output_directory="/var/adm/backup/${1}_${2}"
   backup_log="${output_directory}/backup.log"
   backup_lis="${output_directory}/backup.lis"
   return $backup_log,$backup_lis
}

prep_directories 20000330 WEEKLY


Executing this script results in the following error.

    prep_directories: bad math expression: unbalanced stack [75]

I assume it has something to do with the slashes (/) found in the string
that it is attempting to return.

Any and all suggestions will be greatly appreciated.

Thanks,

Allen Belk

 | Allen Belk, Systems Manager
 | Office of Technology Resources
 | University of Southern Mississippi
 | allen.belk@usm.edu  601.266.6013




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

* RE: returning a pathname from a function
  2000-03-30 20:56 returning a pathname from a function Allen Belk
@ 2000-03-31  5:47 ` Andrej Borsenkow
  0 siblings, 0 replies; 2+ messages in thread
From: Andrej Borsenkow @ 2000-03-31  5:47 UTC (permalink / raw)
  To: Allen Belk, zsh-workers

> prep_directories()
> {
>    output_directory="/var/adm/backup/${1}_${2}"
>    backup_log="${output_directory}/backup.log"
>    backup_lis="${output_directory}/backup.lis"
>    return $backup_log,$backup_lis
> }
>
> prep_directories 20000330 WEEKLY
>
>
> Executing this script results in the following error.
>
>     prep_directories: bad math expression: unbalanced stack [75]
>


You cannot return string. return expects arithmetic expression as
status. I agree, that message is a bit weird ... what exact vesion do
you have?

What you try to do? Either output result using echo or print builtin:

	print $backup_log,$backup_lis

in this case you can do something like

	DIRS=$(prep_directories 20000330 WEEKLY)

or you can set parameter explicitly in function:

	DIRS=$backup_log,$backup_lis

-andrej


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

end of thread, other threads:[~2000-03-31  5:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-03-30 20:56 returning a pathname from a function Allen Belk
2000-03-31  5:47 ` Andrej Borsenkow

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