Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

RE: returning a pathname from a 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]
>


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



Messages sorted by: Reverse Date, Date, Thread, Author