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

Re: Autoloaded bash shell scripts treated as zsh



On Mar 7, 11:41pm, zzapper wrote:
}
} autoload ${fpath[1]}/*(:t) #autoload all functions in $fpath

Well, as you discovered, this actually means:  "Assume the name of
every file in $fpath is also the name of a zsh function, and create
an autoload for every function so named."

} As I also use the same directory for my legacy bash scripts, I was
} unpleasantly surprised to find that these scripts had also been
} autoloaded and were now being treated as zsh scripts.

How (and why) did you expect zsh to tell the two sets of functions
apart if you put them all in the same directories? There's no magic
here; zsh doesn't examine the contents of the files for #! lines or
anything like that -- for one thing, many functions don't have a #!
line because they're not designed to be executed as standalone scripts.  

} Easy to fix, either I make the scripts zsh compatible or move them
} elsewhere.

A third possibility is to zcompile only the zsh functions, then use
"autoload -w" to load them.

} Q2) I was surprised to what extent my bash scripts worked as zsh
} (mostly only required the adding of a pre-declaration of any
} variables), is a reasonable proportion of bash available from within
} zsh?

Both bash and zsh are to a significant degree compatible with the
POSIX shell standard, so yes, they have a lot of overlap, and if you
don't use any of the special features of either shell, then the same
scripts and functions should work in both.



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